9Google AdSense

11716 Digital Fortress

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

int main()
{

    char str[10010],str1[100][100]={0},c;
    long int x,y,len,store,g;
    long int test,i,a,b,p,h,j;
    scanf("%ld",&test);
    scanf("%c",&c);
    for(i=1;i<=test;i++)
    {
    store=0;
    gets(str);
    len=strlen(str);
    x=sqrt(len);
    if(x*x==len)
    {
    store=x;

    p=0;
    for(a=0;a<store;a++)
        for(b=0;b<store;b++)
             str1[a][b]=str[p++];
    for(g=0;g<store;g++)
    {
        for(h=0;h<store;h++)
            printf("%c",str1[h][g]);
    }
    }
    else
        printf("INVALID");
    printf("\n");
    }
    return 0;
}

No comments: