Problem Description
使用1角、2角和5角的硬币组成1元钱,编程计算有多少种组成方法。
Input Description
无。
Output Description
输出组成方法的种数(一个整数)。
答案:
#include <stdio.h>//用枚举
int main()
{
int x, y, z, m;
int count = 0;
x = 1;
y = 2;
z = 5;
for(int a = 0; a <= 10; a++)
{
for(int b = 0; b <= 5; b++)
{
for(int c = 0; c <= 2; c++)
{
m = (a * x) + ( b * y) + (c * z);
if(m == 10)
count++;
}
}
}
printf("%d", count);
return 0;
}