#include<stdio.h>
void main ( )
{
int a;
float b,sum;
printf("有三辆车供你选择:\n");
printf("1.夏利\n");
printf("2.富康\n");
printf("3.桑塔纳\n");
printf("请选择车型:\n");
scanf("%d",&a);
printf("请输入公里数:\n");
scanf("%f",&b);
switch(a)
{
case 1:
{if(b>=3) sum=7+(b-3)*2.1; else sum=7;} break;
case 2:
{if(b>=3) sum=8+(b-3)*2.4; else sum=8;} break;
case 3:
{if(b>=3) sum=9+(b-3)*2.7; else sum=9;} break;
}
printf("一共是%f元\n",sum);
}
我也是新手,我稍微完善了一下