5 athletes took part in the 10-metre diving competition, and some people asked them to predict the outcome of the game.
A contestant said: B First, I third.
B contestant said: I second, e fourth.
C contestant said: I first, d second.
D contestant said: C Finally, I third.
E contestant said: I am four, a first.
After the game is over, each player is half right, please program to determine the position of the match.
Code implementation:
#include <stdio.h>int main () { int a=0,b=0,c=0,d=0,e=0; int flag=0; Int ret=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 ((1== (b==1) + (a==3)) && (1== (b= =2) + (e==4)) && (1== (c==1) + (d==2)) && (1== (c==5) + (d==3)) && (1== (e==4) + (a==1)) { flag=0; ret=0; Ret|= (1<< (A-1)); &NBSP;&NBsp; ret|= (1<< (b-1)); ret|= (1< < (c-1) ret|= (1<< (d-1)); ret|= (1<< (e-1)); while (ret) { if (ret%2==0) { flag=1; break; } ret/=2; } if (flag==0) { printf ("a=%d b=%d c=%d d=%d e=%d\n", A,B,C,D,E); } } } } } } } return 0;}
The result: a=2 b=1 c=1 d=3 e=4
This article is from the "Pzd Chuan Feng" blog, please make sure to keep this source http://xujiafan.blog.51cto.com/10778767/1710862
The problem of athlete's diving rank in C language realization