#include<iostream>
#include<Windows.h>
using namespace std;
int main()
{
//tilemap 그리기
//
//10 x 10 크기의 타일 맵그리기
//
//vertical(세로)(열)
//□□□□□□□□□□ horizontal(가로)(행)
//□□□□□□□□□□
//□□□□□□□□□□
//□□□□□□□□□□
//□□□□□□□□□□
//□□□□□□□□□□
//□□□□□□□□□□
//□□□□□□★□□□ 7, 6
//□□□□□□□□□□
//□□□□□□□□□□
//타일 맵을 그린다.
//입력한 수만큰 그린다.
//10을 입력하면 10x10 타일이 그려진다.(□로 도배)
//숫자 를 입력하면 그 위치가 ★바뀐다.
//배열을 쓰지 않는다.
int tile; // 타일 크기 변수 tile x tile
int x, y; // ★로 바꿀 위치를 정할 변수
cout << "과제1 타일맵 그리기" << endl;
cout << "원하는 ? x ? 타일 크기를 지정하세요 : ";
cin >> tile;
for (int i = 0; i < tile; i++) {
for (int j = 0; j < tile; j++) {
cout << "□";
}
cout << endl;
}
do
{
cout << "★로 바꿀 타일의 위치를 지정하세요 ( " << tile << " x " << tile << " ) : ";
scanf("%d %d", &x, &y);
} while ((x < 1 || x > tile) || (y < 1 || y > tile));
//system("cls");
cout << "과제 1 타일맵 그리기" << endl;
for (int i = 1; i <= tile; i++) {
for (int j = 1; j <= tile; j++) {
if (i == x) { // 입력한 x값과 y값을 판별해
if (j == y) { // 해당 조건이 참이면 ★을 출력
cout << "★";
}
else {
cout << "□";
}
}
else {
cout << "□";
}
}
cout << endl;
}
return 0;
}
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ