C++ 颜色输出设置
#include<bits/stdc++.h>
#include<windows.h>
#define int long long
using namespace std;
void init(){
HANDLE hIn=GetStdHandle(STD_INPUT_HANDLE);
HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
DWORD dwInMode,dwOutMode;
GetConsoleMode(hIn,&dwInMode);
GetConsoleMode(hOut,&dwOutMode);
dwInMode |= 0x0200;
dwOutMode |= 0x0004;
SetConsoleMode(hIn,dwInMode);
SetConsoleMode(hOut,dwOutMode);
}
void setcolor(int wr,int wg,int wb,int br,int bg,int bb){
printf("\033[38;2;%d;%d;%dm\033[48;2;%d;%d;%dm",wr,wg,wb,br,bg,bb);
}
void print(string news,string color){
if (color=="0"){
setcolor(255,255,255,0,0,0);
}
else if (color=="blue"){
setcolor(0,0,255,0,0,0);
}
else if (color=="red"){
setcolor(255,0,0,0,0,0);
}
else if (color=="green"){
setcolor(0,255,0,0,0,0);
}
else if (color=="yellow"){
setcolor(255,255,0,0,0,0);
}
else if (color=="purple"){
setcolor(255,0,255,0,0,0);
}
for (int i=0;i<news.size();i++){
cout<<news[i];
Sleep(15);
}
puts("");
setcolor(255,255,255,0,0,0);
}
signed main(){
init();
print("I_AK_NOI","yellow");
print("I_AK_IOI","blue");
return 0;
}