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