#include <bits/stdc++.h>
using namespace std;
//1337 : 달팽이삼각형
int main()
{
int a[100][100] = {0,},n,x = 0,y = 0,cnt = 0;
cin >> n;
fill(&a[0][0], &a[99][100], -1);
for(;;){
for(int i = 0;i < n;i++){
if(cnt == 10){
cnt = 0;
}
a[x][y] = cnt++;
x++;
y++;
}
n--;
for(int i = 0;i < n;i++){
if(cnt == 10){
cnt = 0;
}
y--;
a[x][y] = cnt++;
}
n--;
for(int i = 0;i < n;i++){
if(cnt == 10){
cnt = 0;
}
x--;
a[x][y] = cnt++;
}
x++;
y++;
if(a[x][y] != -1){
break;
}
}
for(int i = 0;i < 20;i++){
for(int j = 0;j < 20;j++){
//if(a[i][j] != 0){
printf("%3d",a[i][j]);//cout << << " ";
//}
}
cout << "\n";
}
return 0;
}
'정보올림피아드-KOI > 기초 문법 문제' 카테고리의 다른 글
BFS - 파이썬 (0) | 2021.02.04 |
---|---|
DFS - 인접 리스트 (0) | 2021.02.04 |
2071 : 파스칼 삼각형 (0) | 2021.01.26 |
1337 : 달팽이삼각형 (0) | 2021.01.26 |
Stack - 파이썬 (0) | 2021.01.24 |