1 /* 2 百文买鸡 3 公鸡5/只 母鸡3/只 小鸡3只/文 4 求百文百只里面的组合 5 */ 6 int main() 7 { 8 int cock, hen, chick; 9 for (cock = 0; cock < 100 / 5;cock++) 10 { 11 for (hen = 0; hen < 100 / 3;hen++) 12 { 13 chick = 100 - (cock + hen); 14 if ((cock * 5+hen*3+chick/3)==100) 15 { 16 if (cock+hen+chick==100) 17 { 18 printf("cock=%d hen=%d chick=%d\n", cock, hen, chick); 19 } 20 } 21 } 22 } 23 24 25 26 return 0; 27 }
原文地址:https://www.cnblogs.com/old-horse/p/12685807.html
时间: 2024-10-11 01:59:00