- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- float a,b;
- int c,d,e,f,fhd,ohd,ftd,td,fd;
- cout<<"input prize: ";
- cin>>a;
-
- cout<<"input your money: ";
- cin>>b;
- d=b*100;
- while(b<a)
- {
- cout<<"Not enough money, Error\nInput money: ";
- cin>>b;
- }
- if(b>=a*1000)
- {
- cout<<"two much money bro!";
- }
- else if(b>a)
- {
- c=a*100;
- d=b*100;
- e=d-c;
- cout<<"give change: "<<e/100<<" dollars\n\n";
- fhd=e/50000;
- e=e%50000;
- ohd=e/10000;
- e=e%10000;
- ftd=e/5000;
- e=e%5000;
- td=e/1000;
- e=e%1000;
- fd=e/500;
- e=e%500;
- cout<<"give change:\n"<<fhd<<"five hundred dollars\n"<<ohd<<"one hundred dollars\n"<<ftd<<"fifty dollars\n"<<td<<"ten dollars\n"<<fd<<"five dollars\n"<<e/100<<"dollars\n";
- }
- else
- {
- cout<<"\njust enough!";
- }
- cout<<"Thank you!\n";
- system("pause");
- return 0;
- }
複製代碼 |