#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
#include<string>
using namespace std;
string maps[60];
int board_size;
void reset_board(int size);
void draw_board();
int main()
{
int select = 0;
while(select != 3)
{
cout << " - Map size -" << endl;
cout << "1. Easy(8*8)" << endl;
cout << "2. Nomal(13*13)" << endl;
cout << "3. Hard(19*19)" << endl;
cout << "4. Exit" << endl;
cout << ": " << endl;
select = getchar() - '1';
getchar();
if(select >= 0 && select <= 2)
{
const int board_size[] = {8, 13, 19};
reset_board(board_size[select]);
draw_board();
}
}
system("pause");
return 0;
}
void reset_board(int size) //표값 초기화
{
board_size = size;
int y = 0;
maps[y] = "┏";
for(int x = 0; x < size - 1; ++x)
{
maps[y] += "━┳";
}
maps[y++] += "━┓";
while(y < size * 2 - 1)
{
maps[y] = "┃";
for(int x = 0; x < size - 1; ++x)
{
maps[y] += " ┃";
}
maps[y++] += " ┃";
maps[y] = "┣";
for(int x = 0; x < size - 1; ++x)
{
maps[y] += "━╋";
}
maps[y++] += "━┫";
}
maps[y] = "┃";
for(int x = 0; x < size - 1; ++x)
{
maps[y] += " ┃";
}
maps[y++] += " ┃";
maps[y] = "┗";
for(int x = 0; x < size - 1; ++x)
{
maps[y] += "━┻";
}
maps[y] += "━┛";
}
void draw_board()
{
system("cls");
for(int i = 0; i < board_size * 2 + 1; ++i)
{
cout << maps[i] << endl;
}
}
메뉴 선택루프 잘 봐.
select != 3 뜻이 3과 같지 않을때 아님 ??
응 3되면 빠져나오게 하려고
아 -'1'을해줘서 0~2구나
select = getchar() - '1'; 이것 때문에
그렇지. '4' 가 3 이 되지.
저 const는 네이버에 쳤을때 변수를 > 상수로 바꿔버린다고 나오는데
const board_size[]{8, 13 ,19} 면은 board_size[3] 이되고 [1]에는 8 [2]에는13 [3]에는 19
아아아 인덱스 0부터지 그럼 [0]~[2] 다음에 [select]가 들어오니까 0이라하면 8
8이 reset_board(int size) <ㅡ size로 들어오고 board_size는 전역함수니까 8로되고
올 이해완료
아리가또 센세!
ㅇㅇ 굿굿~
http://dblack.tk
커뮤니티 사이트 입니다 많은 이용 부탁 드립니다.