1069 microblogging forward lottery

1069 microblogging forward draw (20 points)

Xiao Ming PAT exam out, glad I decided to launch microblogging forward raffle, users from forwarding N in order to send a red envelope every individual. Please write a program to help him determine the list of winners.

Input formats:

Input of the first line gives three positive integers M (≤ 1000), N, and S, respectively, the total amount of forwarding, Xiaoming winning interval determined, and the first number of winners (numbering starting from 1). Subsequently M rows, the order given users Forward microblogging nickname (no more than 20 characters, the string does not contain the non-empty spaces carriage return).

Note: Some people may forward many times, but not winning many times. So if you are in the winning position of the current users have won anything, he skipped sequentially removed one.

Output formats:

Output list of winners in the order entered, each nickname per line. If there is no winner, the output  Keep going....

Sample Input 1:

9 3 2
Imgonnawin!
PickMe
PickMeMeMeee
LookHere
Imgonnawin!
TryAgainAgain
TryAgainAgain
Imgonnawin!
TryAgainAgain

Output Sample 1:

PickMe
Imgonnawin!
TryAgainAgain

Sample Input 2:

2 3 5
Imgonnawin!
PickMe

Output Sample 2:

Keep going...
#include <iostream>

using namespace std;

int main()
{
    int m,n,s;
    cin>>m>>n>>s;
    string name[m];
    for(int j=0;j<m;j++)
    {
        cin>>name[j];
    }
    string jiang[m];
    int count=1;
    if(s>m)
    {
        cout<<"Keep going...";
    }
    else
    {
        int i=s-1;
        jiang[0]=name[i];
        count=1;
        i=i+n;
        while(i<m)
        {
            int t=0;
            for(int i1=0;i1<count;i1++)
            {
                if(name[i]==jiang[i1])
                {
                    t=1;
                }
            }
            if(t==0)
            {
                jiang[count]=name[i];
                count++;
                i+=n;
            }
            else
            {
                i++;
            }
        }
        for(int j1=0;j1<count;j1++)
        {
            cout<<jiang[j1];
            if(j1!=count-1)
            {
                cout<<endl;
            }
        }
    }
    return 0;
}

 

Published 60 original articles · won praise 2 · Views 2059

Guess you like

Origin blog.csdn.net/qq_41423485/article/details/89362839