#include <stdio.h>
#include <math.h>
#define MAX 10
void printMatrix(int mat[MAX][MAX],int rows, int cols)
{
int i,j;
for(i=0;i<rows;i++)
{
for(j=0;j<cols;j++)
}
}
int symmetry(int mainmatrix[MAX][MAX], int size) {
int isqrtSize
= (int)sqrt((double)size
); if(isqrtSize*isqrtSize!=size)
return -1;
int i, j;
for(i=0;i<isqrtSize;i++){
for(j=0;j<isqrtSize;j++) {
if(mainmatrix[i][j]!=mainmatrix[j][i]) {
return -1;
}
}
}
return 0;
}
int main()
{
int mat[MAX][MAX]={0};
int i,j,ret;
mat[0][0]=14;
printMatrix(mat,1,1);
ret=symmetry(mat,1);
mat[0][1]=mat[1][0]=mat[1][1]=2;
printMatrix(mat,2,2);
ret=symmetry(mat,4);
mat[0][1]=3;
printMatrix(mat,2,2);
ret=symmetry(mat,4);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CgojZGVmaW5lIE1BWCAxMAoKdm9pZCBwcmludE1hdHJpeChpbnQgbWF0W01BWF1bTUFYXSxpbnQgcm93cywgaW50IGNvbHMpCnsKICAgIGludCBpLGo7Cglmb3IoaT0wO2k8cm93cztpKyspCgl7CgkJZm9yKGo9MDtqPGNvbHM7aisrKQoJCSAgcHJpbnRmKCIlZCAiLG1hdFtpXVtqXSk7CgkJcHJpbnRmKCJcbiIpOwoJfQp9CgppbnQgc3ltbWV0cnkoaW50IG1haW5tYXRyaXhbTUFYXVtNQVhdLCBpbnQgc2l6ZSkgewogICAgaW50IGlzcXJ0U2l6ZT0gKGludClzcXJ0KChkb3VibGUpc2l6ZSk7CiAgICBpZihpc3FydFNpemUqaXNxcnRTaXplIT1zaXplKSAKICAgICAgICByZXR1cm4gLTE7CiAgICBpbnQgaSwgajsKICAgIGZvcihpPTA7aTxpc3FydFNpemU7aSsrKXsKICAgICAgICBmb3Ioaj0wO2o8aXNxcnRTaXplO2orKykgewogICAgICAgICAgICBpZihtYWlubWF0cml4W2ldW2pdIT1tYWlubWF0cml4W2pdW2ldKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gLTE7IAogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIDA7IAp9CgppbnQgbWFpbigpCnsKCWludCBtYXRbTUFYXVtNQVhdPXswfTsKCWludCBpLGoscmV0OwoKCQkJCgltYXRbMF1bMF09MTQ7CglwcmludE1hdHJpeChtYXQsMSwxKTsKCXJldD1zeW1tZXRyeShtYXQsMSk7CglyZXQ9PTAgPyBwcmludGYoInN5bW1ldHJpY1xuIikgOiBwcmludGYoIm5vdCBzeW1tZXRyaWNcbiIpOyAKCQoJbWF0WzBdWzFdPW1hdFsxXVswXT1tYXRbMV1bMV09MjsKCXByaW50TWF0cml4KG1hdCwyLDIpOwoJcmV0PXN5bW1ldHJ5KG1hdCw0KTsKCXJldD09MCA/IHByaW50Zigic3ltbWV0cmljXG4iKSA6IHByaW50Zigibm90IHN5bW1ldHJpY1xuIik7CgoJbWF0WzBdWzFdPTM7CglwcmludE1hdHJpeChtYXQsMiwyKTsKCXJldD1zeW1tZXRyeShtYXQsNCk7CglyZXQ9PTAgPyBwcmludGYoInN5bW1ldHJpY1xuIikgOiBwcmludGYoIm5vdCBzeW1tZXRyaWNcbiIpOwoJCglyZXR1cm4gMDsKfQ==