level 8



#include<stdio.h>#include<conio.h>
#define MAX_INPUT 100
int main(){
int matrix[MAX_INPUT] = {};
int i=0;
int n=0;
int ch;
printf("Press Enter Change Line,Press Q End\n");
while (i < MAX_INPUT){
ch = _getch();
if (ch > 47 && ch <58) {
printf("%c ",ch);
matrix[i] = ch-48;
i++;
continue;
} else
if (ch == 13) printf("\n");
else
if (ch =='Q') break;
}
int size = i;
for(int i=0;i*i <= MAX_INPUT;i++){
if (size == i*i){
n=i;
break;
}
}
printf("\n");
if (n==0) printf ("this isn't rect,plesase restart this program"); else printf("this is rect");
printf("\n size: %d,n: %d\n",size,n);
int rect[n][n];
int new_rect[n][n];
for(int y=0;y < n;y++){
for(int x=0;x < n;x++){
rect[x][y] = matrix[x+y*n];
}
}
for(int y=0;y < n;y++){
for(int x=0;x < n;x++){
new_rect[x][y] = rect[(y)][((n-1)-x)];
}
}
printf("new rect:\n");
for(int y=0;y < n;y++){
for(int x=0;x < n;x++){
printf("%d ",new_rect[x][y]);
}
printf("\n");
}
_getch();
}



