Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- 코딩테스트
- 프로그래밍
- backend
- frontend
- 빅데이터
- 사물인터넷
- 프로그래머스
- 이웃한 칸
- 주가예측
- 모의 주식
- 개발자
- java정리
- 코테
- SNS
- 자바독학
- 풀스택프레임워크
- 백준
- 자바정리
- 개발
- 자바
- 코딩독학
- 코딩
- 개인프로젝트
- java
- Project
- 코스닥
- Python
- C++
- Reflex
- 프로그램
Archives
- Today
- Total
Creative Code
콘솔-(3) 본문
#include <iostream>
#include <conio.h>
#include <Windows.h>
using namespace std;
// 16가지 ANSI 컬러를 열거형으로 정의
enum color16 {
Black = 0,
Blue,
Green,
Cyan,
Red,
Magenta,
Brown,
Lightgray,
Darkgray,
Lightblue,
Lightgreen,
Lightcyan,
Lightred,
Lightmagenta,
Yellow,
White
};
// 콘솔 창 내의 커서 위치를 x, y 좌표로 이동하는 함수 정의
void gotoxy(int x, int y) {
COORD pos = { x, y }; // COORD 구조체를 사용하여 커서 위치를 설정합니다.
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); // 커서 위치를 변경합니다.
}
// 텍스트 색상과 배경 색상을 설정하는 함수 정의
void setcolor(int txtcolor, int color) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), txtcolor + color * 16); // 텍스트 색상과 배경 색상을 설정합니다.
}
int main() {
srand(time(NULL)); // 난수 생성기 초기화
setcolor(Lightblue, White); // 초기 텍스트 색상과 배경 색상 설정
for (int i = 0; i < 16; i++) { // 16번 반복
setcolor(rand() % 16, rand() % 16); // 랜덤한 텍스트 색상과 배경 색상 설정
cout << "******" << endl; // '*' 문자를 출력합니다.
}
}