1 //5.公鸡5元一只,母鸡3元一只,小鸡1元3只,求100元刚好买100只鸡的可能 2 3 #include<stdio.h> 4 5 int main(int argc, char** argv) 6 { 7 int i = 0; 8 int j = 0; 9 10 for (i = 0; i <= 20; i++) 11 { 12 for (j = 0; j <= 30; j++) 13 { 14 if ( (0 == ((100-i-j)%3)) && (100 == 5*i + 3*j + (100-i-j)/3)) 15 printf("gongji:%d,muji:%d,xiaoji:%d\n", i, j, (100-i-j)); 16 } 17 } 18 19 return 0; 20 }
时间: 2024-11-04 13:17:05