wrong answer in magic square pallendrome

Post here if you don't find any other place for your post. But please, stay on-topic: algorithms, programming or something related to this web site and its services.

Moderator: Board moderators

Post Reply
kaiser harlequin
New poster
Posts: 2
Joined: Sat Jan 21, 2017 10:07 am

wrong answer in magic square pallendrome

Post by kaiser harlequin »

#include <iostream>
#include<math.h>
#include<stdio.h>
using namespace std;

int main() {

string w;

int quit[999],lo,al[999];
//getline(cin,w);
cin>>lo;

cin.ignore(256, '\n');


for(int y=0;y<lo;y++)
{

int u=0,x=0,qw;
float r;
char f[1000][1000];
string str,we="";
getline(cin, str);

//cout<<str;
for(long long int i=0;i<str.length();i++)
{
int b=str;

if(b>=97 && b<=122)
we=we+str;

}
//cout<<we<<endl;
r=sqrt(we.length());
qw=(int)r;
//cout<<qw;
if(qw==r)
{
for(long long int ty=0;ty<qw;ty++)
{
for(long long int qe=0;qe<qw;qe++)
{
f[ty][qe]=we[x];
++x;
}
}
for(long long int hy=0;hy<qw;hy++)
{
for(long long int rq=0;rq<qw;rq++)
{

//cout<<f[hy][rq];
if(f[hy][rq]!=f[rq][hy])
++u;
}
//cout<<endl;
}

}
else u=1;
//cout<<u;

quit[y]=u;
al[y]=qw;
}
for(int p=0;p<lo;p++)
{
if(quit[p]==0)
{


cout<<"Case #"<<p+1<<":"<<endl;
if(p!=(lo-1))
cout<<al[p]<<endl;
else cout<<al[p];

}


else
{cout<<"Case #"<<p+1<<":"<<endl<<"No magic :(";
if(p!=(lo-1))
cout<<endl;

}
}




}
lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: wrong answer in magic square pallendrome

Post by lighted »

Your code gets compile error.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Post Reply

Return to “Other words”