#include <stdio.h> #define MAX 100 int square(int n, int squ[][MAX]); void pr(int n, int squ[][MAX]); int main(void) { int n, i, j; int squ[MAX][MAX]={0}; scanf("%d", &n); square(n, squ); pr(n, squ); return 0; } void pr(int n, int squ[][MAX]) { int i, j; for(i=0; i<n; i++) { for(j=0; j<n; j++) { printf("%2c ", squ[i][j]); } printf("\n"); } } int square(int n, int squ[][MAX]) { int x=0, y=0, c1=0, c2=n; char a=0; int divnum=26; while(y<c2) { while(y<c2) { squ[x][y++]=((a++)%divnum)+'A'; } y--; x++; while(x<c2) { squ[x++][y]=((a++)%divnum)+'A'; } x--; y--; c2--; while(y>=c1) { squ[x][y--]=((a++)%divnum)+'A'; } x--; y++; c1++; while(x>=c1) { squ[x--][y]=((a++)%divnum)+'A'; } x++; y++; } return 0; }
2017.11.18 11:06
정올 달팽이 사각형
조회 수 276 추천 수 0 댓글 0