Find the Water King (ii)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.