c 语言编程题,用100元人民币兑换10元,5元和1元的纸币(每一种都要)共50张,请用穷举法编程计算机共有集中兑换方案,每种方案各兑换多少张10元,5元和1元纸币
#include <stdio.h>
int main() {
int c = 0;
for (int s = 1; s <= 9; s++)
for (int w = 1; w <= 17; w++)
for (int y = 1; y <= 50 - s - w; y++)
if (10 * s + w * 5 + y == 100 && s + w + y == 50) {
c++;
printf("十元%2d张 五元%2d张 一元%2d张\n", s, w, y);
}
printf("共有%d种\n", c);
return 0;
}