我是基督徒,我目前是 C++ 的初学者,正在努力学习,但我想我已经到了极限,我已经尝试过其他事情,但我似乎无法让我的程序正常工作。这也是我的课程要求之一,我真的很难弄清楚如何解决这个问题。
基本上用户将输入站(a,b,c)并且程序应该计算费用但是在输入a,b或c之后程序输出0.00000然后任何键都会自动关闭界面。
这是我想使用的代码示例:
#include<stdio.h>
#include<conio.h>
main()
{
float fee, to, from, a, b, c;
printf("Enter your current station: ");
scanf("%f",&from);
printf("Enter the station you want to go: ");
scanf("%f",&to);
if((to == a && from == b))
a = 10;
b = 15;
fee = to + from;
printf("%f", fee);
if((to == b && from == a))
a = 10;
b = 15;
fee = to + from;
printf("%f", fee);
if((to == c && from == a))
a = 10;
c = 5;
fee = to + from;
printf("%f", fee);
if((to == a && from == c))
a = 10;
c = 5;
fee = to + from;
printf("%f", fee);
if((to == b && from == c))
a = 10;
c = 5;
fee = to + from;
printf("%f", fee);
getch();
}
希望有人可以帮助我,感谢您的阅读,我真的很感激。