案例
#include <stdio.h>
int main(){
int age = 0;
printf("输入年龄:");
scanf("%d",&age);
int time = 0;
printf("输入时间:");
scanf("%d",&time);
int isVip = 0;
printf("输入是否会员(1:是,0:否):");
scanf("%d",&isVip);
printf("您的年龄是%d,看电影的时间是:%d ,是否会员:%d \n",age,time,isVip);
double price = 0;
if(time < 12){
price = 50.0;
}else{
price = 80.0;
}
if(age <= 6){
price *=0.5;
} else if(age >= 60){
price *= 0.7;
}else{
price *=1;
}
if(isVip){
price *= 0.9;
}
if ((age <=6 || age >= 60) && time >= 12){
price -= 10;
}
printf("您需要付费:%d元", (int)(price)) ;
}