#include<stdio.h>
int main()
{
int money,n1,n2,n5,count;/*每种硬币至少有一枚,所以本题n1,n2,n5不能=0*/
count=0;
scanf("%d",&money);
if(money<=8||money>=100){
printf("Invalid!");
}else{
for(n5=money/5; n5>0; n5--){
for((n2=money-n5*5)/2; n2>0; n2--){
for(n1=money-n5*5-n2*2; n1>0; n1--){
if(n5*5+n2*2+n1==money){
printf("fen5:%d, fen2:%d, fen1:%d, total:%d\n", n5,n2,n1,n1+n2+n5);
count++;
}
}
}
}
}
printf("count = %d",count);
return 0;
}
标签:count,硬币,money,n5,printf,n1,n2,习题 From: https://www.cnblogs.com/ytmsnzy/p/16588226.html