一道题
用1元,2元,5元,10元,20元,50元主成100块的方法,求算法部分.高手in
#include <stdio.h>
int main(void)
{
int one,two,five,ten,twenty,fifty;
for(one=1; one<=100; one++)
for(two=1; two<=50; two++)
for(five=1; five<=20; five++)
for(ten=1; ten<=10; ten++)
for(twenty=1; twenty<=5; twenty++)
for(fifty=1; fifty<=2; fifty++)
if(one+2*two+5*five+10*ten+20*twenty+50*fifty==100){
printf(" One : %d\n", one);
printf(" Two : %d\n", two);
printf(" Five : %d\n", five);
printf(" Ten : %d\n", ten);
printf("Twenty : %d\n", twenty);
printf(" Fifty : %d\n", fifty);
printf("\n\n");
}
return 0;
}