#include <iostream>
using namespace std;
void main(){
float m,n;
float a; //a应该为float,否则一减就只剩下整数了
int dollar,cent1,cent2,cent3,cent4,cent5,cent6,cent7,cent8;
cout<<"################################################################################";
cout<<"
欢迎使用本程序
";
cout<<"
本程序主要由%何/完成
";
cout<<"
";
cout<<"
By SharpshootER
";
cout<<"################################################################################";
cout<<endl;
cout<<"################################################################################";
cout<<"
本程序可使用的金额为100 50 20 10 5 1 0.5 0.1 单位-元;
";
cout<<"
";
cout<<"################################################################################";
cout<<endl;
cout<<"请输入应收的金额:";
cin>>m;
cout<<endl;
L1:cout<<"请输入实收的金额:";
cin>>n;
cout<<endl;
while(n<m){
cout<<"实收金额不足!"<<endl;
goto L1; goto L2;}
L2:a=n-m;
dollar=a*10;
cent1=dollar/1000;
cent2=(cent1%1000)/500;
cent3=((cent1%1000)%500)/200;
cent4=(((cent1%1000)%500)%200)/100;
cent5=((((cent1%1000)%500)%200)%100)/50;
cent6=(((((cent1%1000)%500)%200)%100)%50)/10;
cent7=((((((cent1%1000)%500)%200)%100)%50)%10)/5;
cent8=(((((((cent1%1000)%500)%200)%100)%50)%10)%5)/1;
cout<<"找零:"<<endl<<endl;
cout<<"100元:"<<cent1<<"张."<<endl;
cout<<"50元:"<<cent2<<"张."<<endl;
cout<<"20元:"<<cent3<<"张."<<endl;
cout<<"10元:"<<cent4<<"张."<<endl;
cout<<"5元:"<<cent5<<"张."<<endl;
cout<<"1元:"<<cent6<<"张."<<endl;
cout<<"0.5元:"<<cent7<<"张."<<endl;
cout<<"0.1元:"<<cent8<<"张."<<endl;
cout<<endl;
system("pause");
}
请教:
我这样写有什么错么?
为什么编译出来的结果全部为0啊?
我感觉没写错啊。