This problem was supposed to be sorted by structure, and it was annoying to think.
Again to use a tag array, first mark the longest, and then the longest inside mark the most fine, and finally in the mark inside the output number of the largest
#include <iostream>#include<cstring>using namespacestd;Const intC =1010;intA[c];intB[c];intC[c];intSign[c];intMax =0;intMAXC =0;intMin =1000000000;intMain () {intN; CIN>>N; intm; while(n--) {Max=0; MAXC=0; Min=1000000000; memset (sign,0,sizeof(sign)); CIN>>m; for(inti =0; i < m; i + +) Cin>> A[i] >> B[i] >>C[i]; for(inti =0; I < m; i++) if(A[i] >Max) Max=A[i]; for(inti =0; I < m; i++) if(A[i] = =Max) Sign[i]=1; for(inti =0; I < m; i++) if(Sign[i]&&b[i] <Min) Min=B[i]; for(inti =0; I < m; i++) if(sign[i]&& b[i]! =Min) Sign[i]=0; for(inti =0; I < m; i++) if(sign[i]&& C[i] >Maxc) MAXC=C[i]; cout<< MAXC <<Endl; } return 0; }
The best code, people do not even open the array, saving a lot of code, concise and clear
#include<stdio.h>intMain () {intn,m,i,a,b,c,x,y,z; scanf ("%d",&N); while(n--) {scanf ("%d",&m); A=0; b=0; c=0; for(i=0; i<m;i++) {scanf ("%d%d%d",&x,&y,&z); if(x>a| | x==a&&y<b| | X==A&&Y==B&&Z>C) {a=x;b=y;c=Z;} } printf ("%d\n", c); } return 0;}
Nyoj-carefully selected