Poj Solution 3750

http://poj.org/problem?id=3750

#include <stdio.h>
#include <string.h>

int main()
{
    int n, w, s;
    int i, j;
    char name[65][16];
    scanf("%d", &n);
    getchar();
    for (i=0; i<n; ++i)
    {
        gets(name[i]);
    }
    scanf("%d,%d", &w, &s);
    
    i = w-1;
    while (n != 0)
    {
        if (i+s-1 > n-1)
        {
            i = (i+s-1)%n;
        }
        else
        {
            i = i+s-1;
        }
        puts(name[i]);
        for (j=i; j<n-1; ++j)
        {
            strcpy(name[j], name[j+1]);
        }
        --n;
    }
    
    return 0;
}
											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *