AcWing 653. 钞票
原题链接
中等
作者:
Noneday
,
2020-06-03 13:25:01
,
所有人可见
,
阅读 507
#include <iostream>
using namespace std;
int main()
{
int a;
int arr[] = { 100,50,20,10,5,2,1 };
int as[] = {0,0,0,0,0,0,0};
int *pr = arr;
int *ps = as;
int len = sizeof(arr) / sizeof(arr[0]);
int cnt = 0;
cin >> a;
cout<<a<<endl;
while (a > 0)
{
while (a - *pr >= 0)
{
*ps += 1;
a -= *pr;
}
cout <<*ps<<" nota(s) de R$ "<<*pr<<",00"<<endl;
pr += 1;
ps += 1;
cnt += 1;
}
while (cnt<len)
{
cout << *ps << " nota(s) de R$ " << *pr << ",00" << endl;
ps += 1;
pr += 1;
cnt += 1;
}
}