#include <stdlib.h>
int main ()
{
System ("COLOR 3 a");
System ("pause");
return 0;
}
Explain the color behind 3 is the background color code A is the front color code, you can change according to these codes
0= Black
1= Blue
2= Green
3= Lake Blue
4= Red
5= Purple
6= Yellow
7= White
8= Gray
9= Light Blue
A= Light Green
b= Light Green
c= Light Red
d= Lavender
E= Light Yellow
f= Bright White
#include "stdafx.h"
#ifdef WIN32
#include <Windows.h>
#endif
#include <time.h>
# Include <stdlib.h>
#include <string.h>
int _tmain (int argc, _tchar* argv[])
{while
(1)
{
Srand (Time (NULL));
int _nprecolorflag = rand ()%;
int _nbackcolorflag = rand ()% 6;
char _cbackcolorflag;
Switch (_nbackcolorflag)
{case
0:{_cbackcolorflag = ' A ';
Case 1:{_cbackcolorflag = ' B ';
Case 2:{_cbackcolorflag = ' C ';
Case 3:{_cbackcolorflag = ' D ';
Case 4:{_cbackcolorflag = ' E ';
Case 5:{_cbackcolorflag = ' F '; break;}
}
Char strcolorformat[256];
sprintf (Strcolorformat, "Color %d%c", _nprecolorflag,_cbackcolorflag);
System (Strcolorformat);
printf ("---------console window color show----------------\ n");
Sleep (1000);
System ("CLS");
}
return 0;
}