I'm getting CE for this code, I don't how to change it, can anyone help ?
- Code: Select all
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
int n;
cin>>n;
getchar();
for(int i=1; i<=n; i++){
char ciph[10010], deciph[10010];
int len, sq;
gets(ciph);
len = strlen(ciph);
sq = sqrt( (float)len );
if( sq*sq != len ) cout<<"INVALID"<<endl;
else{
int dex=0;
for(int j=0; j<sq; j++ )
for(int k=0; k<sq; k++, dex++)
deciph[dex] = ciph[ sq*k + j ];
deciph[dex]=NULL;
cout<<deciph<<endl;
}
}
return 0;
}
