How to realize a flashing Christmas tree in C language
Editor to share with you how C language to achieve a flickering Christmas tree, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article. Let's learn about it!
Effect picture
Fig. 1 Christmas tree
Let's take a look at the source code, as shown below:
# include # define N 15char str [] = {'*','','@','\',','$','','%','','&','','!'}; void color (int a) {SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), a) } void getCoord (double y, double x) {COORD pos = {xjingy}; SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), pos);} void hideCursor () {CONSOLE_CURSOR_INFO cursor= {1,0}; SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), & cursor);} void layer (int x, int y, int num, int col) {color (col); getCoord (xjie); int idx = rand ()% N Printf ("% c", str [idx]); for (int k = 1; k