标签:pos out att 绿色 开始 rpo namespace gre attribute
一、挂起
#include<iostream> #include<windows.h> using namespace std; int main() { for (int i = 10; i >= 0; i--) { system("cls"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED); cout << "距离系统关闭还有:"; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); cout << i << "秒" << endl; Sleep(1000); } return 0; }
二、在屏幕随机输出
#include<iostream> #include<windows.h> using namespace std; void gotoxy(int y, int x) { COORD pos; pos.X = x; pos.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); } int main() { gotoxy(8, 20);//从第5行 第20列开始输出 cout << "欢迎来到信息管理系统,请求正在加载中..."; for (int i = 0; i < 5; i++) { Sleep(1000); cout << "..."; } cout << endl; return 0; }
三、颜色控制
#include<iostream> #include<windows.h> using namespace std; void main() { cout << "原色" << endl; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN | FOREGROUND_BLUE); cout << "白色" << endl; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED); cout << "红色" << endl; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN); cout << "绿色" << endl; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE); cout << "蓝色" << endl; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN); cout << "黄色" << endl; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_BLUE); cout << "粉色" << endl; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN |FOREGROUND_BLUE); cout << "青色" << endl; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY); cout << endl; }
标签:pos out att 绿色 开始 rpo namespace gre attribute
原文地址:https://www.cnblogs.com/Gzu_zb/p/9374748.html