Find the Water king

Source: Internet
Author: User

#include <iostream>using namespacestd;#defineMAXSIZE 20voidFindwater (intId[],intLenint&water) {    intCounter=0;//counter     for(intI=0; i<len;i++)    {        if(counter==0)//if the counter is zero{Water=id[i];//record the ID of the current post as the water king suspectcounter++; }        Else        {            if(Water==id[i])//If the water king suspects the same as the following IDcounter++;//The counter is recorded, otherwise minus one            Elsecounter--; }    }}intMainintargcChar*argv[]) {    intId[maxsize];//Post record form    intnum,waterking;//number of posts, water Kingcout<<"Please enter the number of posts:"; CIN>>num; cout<<"Please enter the Post ID:";  for(intI=0; i<num;i++) {cin>>Id[i];    } findwater (id,num,waterking); cout<<"The Water king is:"<<WaterKing<<Endl; return 0;}

Find the Water king

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.