暴力做法
#include <cstdio>
int main(){
int n;
scanf("%d",&n);
printf("%d\n",n);
printf("%d nota(s) de R$ 100,00\n",n/100);
n%=100;
printf("%d nota(s) de R$ 50,00\n",n/50);
n%=50;
printf("%d nota(s) de R$ 20,00\n",n/20);
n%=20;
printf("%d nota(s) de R$ 10,00\n",n/10);
n%=10;
printf("%d nota(s) de R$ 5,00\n",n/5);
n%=5;
printf("%d nota(s) de R$ 2,00\n",n/2);
n%=2;
printf("%d nota(s) de R$ 1,00\n",n/1);
n%=1;
return 0;
}
循环做法
#include <cstdio>
int money[7]={100,50,20,10,5,2,1};
int main(){
int n;
scanf("%d",&n);
printf("%d\n",n);
for(int i=0;i<7;i++){
printf("%d nota(s) de R$ %d,00\n",n/money[i],money[i]);
n%=money[i];
}
return 0;
}