C++
3x3 배열에 문자 주석 아래 행 순서부터 출력
2sac
2024. 11. 1. 20:38
#include <iostream>
#include <cstring>
using namespace std;
char arr[3][3];
int main() {
char a;
cin >> a;
/*
00 01 02
10 11
20
*/
int x = 0;
int y = 2;
int k = 0;
while (y>=0) {
k++;
x = 0;
while (x<k) {
arr[y][x] = a++;
x++;
}
y--;
}
int y1 = 0; int x1 = 0;
while (y1 < 3) {
while (x1 < 3) {
if (arr[y1][x1] == '\0') cout << " ";
else cout << arr[y1][x1];
x1++;
} cout << endl;
x1 = 0;
y1++;
}
return 0;
}
NOP
LM
K