c语言学习

24 阅读1分钟
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("您需要付费: %f元 ",price);

运行效果

image.png

image.png

image.png