1. Design ideas:
If you delete four different IDs each time, then in the remaining list of IDs, the proportion of the original posting ratio greater than 1/4 is still greater than 1/4, you can get the answer by repeating this process, reducing the total number of IDs in the ID list (into smaller issues).
2. The code is as follows:
#include <iostream>using namespacestd;voidFindid (intId[],intNintrightid[]);intMain () {intid[ -]={1,1,1,2,2,2,3,3,3,1,2,3,1,2,3,6}; intn= -; intrightid[3]; Findid (Id,n,rightid); cout<<"the qualifying IDs are:"<<Endl; for(intI=0;i<3; i++) cout<< Rightid[i] <<" "<<Endl; return 0;}voidFindid (intId[],intNintrightid[]) { intfalseid=-1; intnumber[3]; number[0]=number[1]=number[2]=0; rightid[0]=rightid[1]=rightid[2]=Falseid; for(intI=0; i<n;i++) { if(id[i]==rightid[0]) {number[0]++; } Else if(id[i]==rightid[1]) {number[1]++; } Else if(id[i]==rightid[2]) {number[2]++; } Else if(number[0]==0) {number[0]=1; rightid[0]=Id[i]; } Else if(number[1]==0) {number[1]=1; rightid[1]=Id[i]; } Else if(number[2]==0) {number[2]=1; rightid[2]=Id[i]; } Else{number[0]--; number[1]--; number[2]--; } }}
3. Results:
4. Personal Summary:
This time and the last thought is roughly the same, but in some details need to think carefully, through this time the expansion, the topic has a further understanding.
Software Engineering-Find the Water King 2