C语言题目求解
2020-04-24
第五题:
第四题:
#include <stdio.h>
int main() {
for (int i = 0; i <= 20; i++)
for (int j = 0; j <= 33; j++)
if (7 * i + 4 * j == 100)
printf("公鸡有%d只,母鸡有%d只,小鸡有%d只\n", i, j, 100 - i - j);
return 0;
}
第三题:
#include <stdio.h>
int main() {
for (int A = 1; A <= 9; A++)
for (int B = 1; B <= 9; B++)
for (int C = 1; C <= 9; C++)
for (int D = 1; D <= 9; D++)
if (((10 * A + B) * (10 * C + D) ==
(10 * B + A) * (10 * D + C)) &&
A != B &&
A != C &&
A != D &&
B != C &&
B != D &&
C != D) {
printf("%d%d*%d%d", A, B, C, D);
printf("=");
printf("%d%d*%d%d\n", B, A, D, C);
}
return 0;
}