上代码
#include<stdio.h>
#include<conio.h>//为了后面调用getch(),防止生成的exe文件闪退
int main(){
double number = 0;
double price = 0;
//欢迎语
printf("欢迎使用找零计算器1.0版本\n\n使用说明:\n请正确输入票面和实付金额,按回车确认,因为是1.0版本(只学了那么多),所以每次打开只能使用一次,\n想多次使用请多次打开\n\n");
//输入金额和票面
printf("请输入票面:");
scanf("%lf",&number);
printf("请输入实付金额:");
scanf("%lf",&price);
//判断大小
if (number > price){
printf("您的输入有误,请重新正确输入实付金额:");
scanf("%lf",&price);
if (price > number){
printf("应找您%f\n\n感谢您的使用,再见!",price - number);
}else {
printf("你不守规矩,不给你用了!");
}
}else {
printf("应找您%f\n\n感谢您的使用,再见!",price - number);
}
getch();
return 0;
}