5位運動員參加了10米臺跳水比賽,有人讓他們預測比賽結果 A選手說:B第二,我第三; B選手說:我第二,E第四; C選手說:我第一,D第二; D選手說:C最後,我第三; E選手說:我第四,A第一; 比
阿新 • • 發佈:2019-01-28
#include <stdio.h>
int main()
{
int a = 0, b = 0, c = 0, d = 0, e = 0;
for (a = 1; a <= 5; a++)
{
for (b = 1; b <= 5; b++)
{
for (c = 1; c <= 5; c++)
{
for (d = 1; d <= 5; d++)
{
for (e = 1; e <= 5; e++)
{
if (((a == 3) + (b == 2) == 1) &&
((c == 1) + (d == 2) == 1) &&
((b == 2) + (e == 4) == 1) &&
((a == 1) + (e == 4) == 1))
{
if (a*b*c*d*e == 120)
{
printf("%d %d %d %d %d\n", a, b, c, d, e);
}
}
}
}
}
}
}
return 0;
}