1元换零钱问题

//1元换零钱问题
//把1元兑换成1分,2分,5分的硬币,共有多少种不同换法,请编写求解此问题的程序
#include <stdio.h>
int fun(){
    int i,j,k,a,count=0;
    for(i=0;i<=100;i++){
        for(j=0;j<=50;j++){
            for(k=0;k<=20;k++){
                a=1*i+2*j+5*k;
                if(a==100){
                    count++;
                }
            }
        }
    }
    return count; 
} 
int main(){
    int count;
    count=fun();
    printf("1元可以兑换的硬币方式有%d种\n",count);
    return 0;
} 

 收录于文章《885程序设计考点狂背总目录中

posted @ 2020-08-18 22:34  薄眠抛却陈年事。  阅读(203)  评论(0编辑  收藏  举报