Advertisement
NabilaShova

11716-Digital Fortress

Apr 25th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include <math.h>
  4. int main ()
  5. {
  6.     char a[10000];
  7.     int lenght,t,i,j,b;
  8.     double c;
  9.     scanf("%d", &t);
  10.     getchar ();
  11.     while(t--)
  12.     {
  13.         gets(a);
  14.         lenght=strlen(a);
  15.         c=sqrt(lenght);
  16.         b=c;
  17.         if(c-b!=0)
  18.             printf("INVALID\n");
  19.         else{
  20.                 char x[1000][1000];
  21.             int n=0;
  22.             for(i=0;i<b;i++){
  23.                 for(j=0;j<b;j++)
  24.                     x[i][j]=a[n++];
  25.             }
  26.             for(i=0;i<b;i++){
  27.                 for(j=0;j<b;j++)
  28.                     printf("%c", x[j][i]);
  29.             }
  30.         }
  31.           printf("\n");
  32.         }
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement