UVa Solution 11192 – Group Reverse


The problem link is
 UVa:11192-Group Reverse

Solution:

#include<stdio.h>
#include<string.h>
int main()
{
    int g,i,cnt,j,lenth;
    char str[110];
    while(scanf("%d",&g) && g!=0)
    {
        scanf("%s",str);
        lenth=strlen(str)/g;
        cnt=0;
        for(i=0;i<strlen(str);i++)
        {
            if(i%lenth==0)
            {
                cnt++;
                j=0;
            }
            printf("%c",str[cnt*lenth-j-1]);
            j++;
        }
        printf("\n");
    }
    return 0;
}

Run time: 0.015
User Name on UVA: refatsardar

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: