MY name is ruhul amin

ISLAMIC UNIVERSITY OF KUSHTIA

Sunday, March 3, 2013

uva solve problem 11716 - Digital Fortress Acc

#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
    int p,n,i,j,k,l,s,u,t;
    double r;
    char a[10010],b[102][102];
    while(scanf("%d",&n)!=EOF)
    {
          getchar();
        for(i=1;i<=n;i++)
        {

            gets(a);
            l=strlen(a);
            r=sqrt(l);
            p=r;
            if((r-p)!=0)
            printf("INVALID\n");
            else
            {
                s=0;
                for(j=0;j<p;j++)
                {
                    for(k=0;k<p;k++)
                    {
                        b[j][k]=a[s++];
                    }
                }
                for(u=0;u<p;u++)
                {
                    for(t=0;t<p;t++)
                    printf("%c",b[t][u]);
                }
                printf("\n");
            }
        }
    }
    return 0;
}

No comments:

Post a Comment