请帮我!我的 c++ 程序似乎有错误。代码显示有关面额的错误输出,以比索为单位输入整数。编写一个程序,显示 1000、500、100、50、20 和 10 比索钞票的数量。输出所有面额后的剩余金额。
这是我的程序代码。
#include <iostream>
using namespace std;
int main()
{
int a;
cout << "Enter the amount: ";
cin >> a;
cout << "No. of 1000 peso bills: " << a/1000;
cout << "\nNo. of 500 peso bills: " << a%1000/500;
cout << "\nNo. of 100 peso bills: " << a%500/100;
cout << "\nNo. of 50 peso bills: " << a%100/50;
cout << "\nNo. of 20 peso bills: " << a%50/20;
cout << "\nNo. of 10 peso bills: " << a%20/10;
cout << "\n\nThe rest of the amount: " << a%10;
}
输出显示:
Enter the amount: 34757
No. of 1000 peso bills: 34
No. of 500 peso bills: 1
No. of 100 peso bills: 2
No. of 50 peso bills: 1
No. of 20 peso bills: 0
No. of 10 peso bills: 1
The rest of the amount: 7
Process returned 0 (0x0) execution time : 2.156 s
Press any key to continue.
10 比索钞票的数量必须是 0 而不是 1,我该如何纠正这个问题?提前致谢。