Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

又是一道水淋淋的题目啊!

Posted by 201501060326 at 2016-02-29 18:21:29 on Problem 3750
#include <stdio.h>
struct children
{
    int num;
    char name[100];
};
int main()
{
    struct children ch[1000];
    int i,k,w,s,res,cur,ord;
    scanf("%d",&k);
    getchar();
    for(i=0; i<k; i++)
    {
        gets(ch[i].name);
        ch[i].num=1;
    }
    scanf("%d,%d",&w,&s);
    res=k;
    cur=w-1;
    ord=1;
    while(res>1)
    {
        while(ch[cur].num==0)
        {
            cur=(cur+1)%k;
        }
        if(ord==s)
        {
            ch[cur].num=0;
            ord=0;
            res--;
            puts(ch[cur].name);
        }
        cur=(cur+1)%k;
        ord++;
    }
    for(cur=0; cur<k; cur++)
    {
        if(ch[cur].num!=0)
        {
            puts(ch[cur].name);
            break;
        }
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator