Notice
Recent Posts
Recent Comments
250x250
Creative Code
콘솔-(2) 본문
728x90
#include <iostream>
#include <conio.h>
#include <Windows.h>
using namespace std;
// 콘솔 창 내의 커서 위치를 x, y 좌표로 이동하는 함수 정의
void gotoxy(int x, int y) {
COORD pos = { x, y }; // COORD 구조체를 사용하여 커서 위치를 설정합니다.
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); // 커서 위치를 변경합니다.
}
int main() {
gotoxy(5, 10); // (5, 10) 위치로 커서 이동
cout << "Hello"; // "Hello"를 출력합니다.
gotoxy(20, 15); // (20, 15) 위치로 커서 이동
cout << "World"; // "World"를 출력합니다.
}
#include <iostream>
#include <conio.h>
#include <Windows.h>
using namespace std;
// 콘솔 창 내의 커서 위치를 x, y 좌표로 이동하는 함수 정의
void gotoxy(int x, int y) {
COORD pos = { x, y }; // COORD 구조체를 사용하여 커서 위치를 설정합니다.
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); // 커서 위치를 변경합니다.
}
int main() {
for (int i = 0; i < 10; i++) {
gotoxy(i, i); // (i, i) 위치로 커서 이동
cout << "*"; // '*' 문자를 출력합니다.
gotoxy(9 - i, i); // (9-i, i) 위치로 커서 이동
cout << "*"; // '*' 문자를 출력합니다.
}
}
728x90