#include <stdio.h>
#include <conio.h>
int main()
{
float L=0; //L is litre
float gallon;
gallon = 3.785*L;
char input;
float cost;
printf("Hello, welcome to PetrolUpHere!!\n");
printf("Would u like unleaded or diesel fuel?");
scanf("%c", &input);
printf("Enter the litre you want to fuel:");
scanf("%f", &L);
switch (input) {
case 'u' :
cost = 1.98*gallon;
printf("The cost is :%f ",&cost);
break;
case 'd' :
cost = 1.29*gallon;
printf("The cost is :%f ",&cost);
break;
}
getch();
return 0;
}
该程序无法显示成本结果,仅在我完成输入 scanf 语句和 L 值后才显示成本 = 0.0000。我是c程序的新手,希望能得到帮助。感谢