c语言编程题目求大神帮忙解答

2024-11-18 13:35:59
推荐回答(2个)
回答(1):

#include
int main()
{
char kind;
float sum = 0;
float k = 0;
int count = 0;
while(1)
{
printf("请输入车辆种类:A/B/C\n");
scanf("%c",&kind);
printf("请输入公里数:");
scanf("%f",&k);
switch(kind)
{
case 'A':
case 'a': sum = sum + k*0.5; count++; break;
case 'B':
case 'b': sum = sum + k*0.4; count++; break;
case 'C':
case 'c': sum = sum + k*0.3; count++; break;
}
if(count==50)
{
printf("满50辆车,共收费%f元。",sum);
break;
}
}
return 0;
}

回答(2):

很简单阿