do-while百钱百鸡
1 /*百钱百鸡*/ 2 #include <stdio.h> 3 #include <windows.h> 4 5 int main() { 6 int gj=0, mj=0, xj=0; 7 //int i=1, j=1, k=1; 8 //gj + mj + xj == 100; 9 //gj * 5 + mj * 3 + xj / 3 == 100; 10 do { 11 do { 12 do { 13 if (gj + mj + xj == 100 && gj * 5 + mj * 3 + xj / 3 == 100 && xj % 3 == 0) 14 { 15 printf("%d %d %d\n", gj, mj, xj); 16 } 17 xj++; 18 } while (xj < 99); 19 mj++; 20 xj = 1; 21 } while (mj <99); 22 gj++; 23 mj = 1; 24 } while (gj<99); 25 26 system("pause"); 27 }