题目:
#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;
} else {
price = 80;
}
//检查是否需要年龄优惠
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)) ;// 强制把double 转成int
}
运行结果