文章目录
- AcWing 656. 钞票和硬币
- AC代码
AcWing 656. 钞票和硬币
本题链接:AcWing 656. 钞票和硬币
本博客给出本题截图:
AC代码
代码:
#include <iostream> using namespace std; int main() { double n; cin >> n; int m = n * 100; int num; int q[] = {10000,5000,2000,1000,500,200,100,50,25,10,5,1}; cout << "NOTAS:" << endl; for (int i = 0; i < 6; i ++ ) { num = m / q[i]; printf("%d nota(s) de R$ %.2lf\n", num, double(q[i] / 100.0)); m = m - q[i] * num; } cout << "MOEDAS:" << endl; for (int i = 6; i < 12; i ++ ) { num = m / q[i]; printf("%d moeda(s) de R$ %.2lf\n", num, double(q[i] / 100.0)); m = m - q[i] * num; } return 0; }