圣诞节快到了,不管是抖音,B站,小红书,QQ空间还是自己的朋友圈等等,都有随处可见的圣诞树,可能我们也在各大平台上见过许多圣诞节的代码,可看见那些大佬们写的代码甚是头疼,自己一点都看不懂,且想加入自己的想法元素时不知从何下手,那么我将分享一个有手就行的圣诞树代码,复杂程度零颗星,基本人人都会。(我在普通圣诞树基础上加入了debug窗口文字颜色和背景颜色变化)
话不多说,上代码。
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <Windows.h>
void setColor(unsigned short textColor=0, unsigned short backColor=7){
char command[9]="color 07"; //默认颜色
command[6]='0'+backColor; //将backColor变量改为字符型
command[7]='0'+textColor; //将textColor变量改为字符型
system(command); //调用系统函数
}
int main()
{
enum Color
{
black, blue, green , lakeBlue, red, purple, yellow, white, gray,
lightBlue, lightGreen, lightSimpleGreen, lightRed, lightPurple, lightYellow, brightWhite
};
int i,j;
for(j=0;j<42;j++)
{
printf(" ");
}
printf(&