1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-27 14:36:19 +00:00
202401-programming-assignments/【实践课外】5.循环结构2/7-6 换硬币.c

24 lines
469 B
C
Raw Normal View History

2024-10-30 03:44:18 +00:00
#include <stdio.h>
int main() {
int x, count = 0;
scanf("%d", &x);
for (int i = x / 5; i >= 1; i--) {
for (int j = x / 2; j >= 1; j--) {
for (int k = x; k >= 1; k--) {
if (i * 5 + j * 2 + k == x) {
printf("fen5:%d, fen2:%d, fen1:%d, total:%d\n", i, j, k, i + j + k);
count++;
}
}
}
}
printf("count = %d\n", count);
return 0;
}