#include <iostream>
#include <vector>
using namespace std;
int main() {
// 1. 10 x 10 크기의 모눈종이를 0으로 초기화
int grid[10][10] = {0,};
// 2. 반복문을 돌며 액자 테두리(y가 1 또는 8, x가 1 또는 8) 채우기
// 인덱스 1부터 8까지만 확인하면 됩니다.
for (int y = 1; y <= 8; y++) {
for (int x = 1; x <= 8; x++) {
// y가 시작/끝이거나, x가 시작/끝인 테두리 조건
if (y == 1 || y == 8 || x == 1 || x == 8) {
grid[y][x] = 1;
}
}
}
// 3. 결과 출력 (전체 10 x 10 크기 출력)
for (int y = 0; y < 10; y++) {
for (int x = 0; x < 10; x++) {
cout << grid[y][x] << " ";
}
cout << "\n"; // 한 행이 끝나면 줄바꿈
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: