First, the topic
After a period of time, the king of Water disappeared, there were three water kings, each of whom posted more than 1/4 of the total number.
Request: If you have a list of posts (including replies) for the current forum, and the ID of the author of the Post is in it, can you quickly find the three of them? Second, the idea of solving the problem will be the first to find water king's routine expansion, each delete four different nodes, and finally get three water Wang San, program code
1#include <iostream>2#include <string>3 using namespacestd;4 intMain ()5 {6 //set up an array7 stringid[ -];8 stringking[3] = {"!","!","!"};9 intm1=0, m2=0, m3=0;Ten intI, k, number; Onecout <<"Please enter the number of posts:"; ACIN >>Number ; - if(Number <=0) - { thecout <<"Please re-enter:"; -CIN >>Number ; - } -cout <<"Enter the posting ID:"<<Endl; + for(i =0; I < number; i++) - { +CIN >>Id[i]; A } at //Find the Water king - for(i =0; I < number; i++) - { - if(Id[i] = = king[0]) - { -m1++; in } - Else if(id[i]==king[1]) to { +m2++; - } the Else if(Id[i] = = king[2]) * { $m3++;Panax Notoginseng } - } the return 0; +}
Find the Water King (ii)