#include<stdio.h>
#include <windows.h>
void color(const unsigned short textColor)
{
if(textColor>=0 && textColor<=15)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), textColor);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
}
int main()
{
char a[20];
printf("数字画图帮助:0是空格,1是红色,2是绿色,3是黄色,4是蓝色,5是紫色,6是青色,7是黑色,/是换行。\n\n\n");
printf(“请输入数字\n”);
scanf(“%s”,&a);
for (int i=0;i<20;i++)
switch(a[i]) {
case ‘0’: color(0); printf(“■黑色”); break;
case ‘1’: color(1); printf(“■蓝色”); break;
case ‘2’: color(2); printf(“■绿色”); break;
case ‘3’: color(3); printf(“■湖蓝色”);break;
case ‘4’: color(4); printf(“■红色”); break;
case ‘5’: color(5); printf(“■紫色”); break;
case ‘6’: color(6); printf(“■黄色”); break;
case ‘7’: color(7); printf(“■白色”); break;
case ‘8’: color(8); printf(“■灰色”); break;
case ‘9’: color(9); printf(“■淡蓝色”); break;
case ‘a’: color(10); printf(“■淡绿色”); break;
case ‘b’: color(11); printf(“■淡绿色”); break;
case ‘c’: color(12); printf(“■淡红色”); break;
case ‘d’: color(13); printf(“■淡紫色”); break;
case ‘e’: color(14); printf(“■淡黄色”); break;
case ‘f’: color(15); printf(“■亮白色”); break;
case ‘-’: printf(" “); break;
case ‘/’: printf(”\n"); break;
default :printf(“\n”); break;
}
}