1 #include <stdio.h>
2
3 int main()
4 {
5 int i, j, k, count=1;
6 printf("There are following small exchange plans for 1 Yuan note:\n");
7 for (i=0; i<=100; i++)
8 {
9 for (j=0; j<=100-i; j+=2)
10 {
11 for (k=0; k<=100-i-2*j; k+=5)
12 {
13 if (i + j + k ==100)
14 {
15 printf(count%4?"%d: 1*%d + 2*%d + 5*%d\t":"%d: 1*%d + 2*%d + 5*%d\n", count++, i, j/2, k/5);
16 }
17 }
18 }
19 }
20 return 0;
21 }
[root@localhost 38]# vim exchange.c
[root@localhost 38]# gcc exchange.c
[root@localhost 38]# ./a.out
There are following small exchange plans for 1 Yuan note:
1: 1*0 + 2*0 + 5*20 2: 1*5 + 2*0 + 5*19 3: 1*10 + 2*0 + 5*18
4: 1*15 + 2*0 + 5*17 5: 1*20 + 2*0 + 5*16 6: 1*25 + 2*0 + 5*15 7: 1*30 + 2*0 + 5*14
8: 1*35 + 2*0 + 5*13 9: 1*40 + 2*0 + 5*12 10: 1*45 + 2*0 + 5*11 11: 1*50 + 2*0 + 5*10
12: 1*55 + 2*0 + 5*9 13: 1*60 + 2*0 + 5*8 14: 1*65 + 2*0 + 5*7 15: 1*70 + 2*0 + 5*6
16: 1*75 + 2*0 + 5*5 17: 1*80 + 2*0 + 5*4 18: 1*85 + 2*0 + 5*3 19: 1*90 + 2*0 + 5*2
20: 1*95 + 2*0 + 5*1 21: 1*100 + 2*0 + 5*0