写了一个祝福语,祝福武汉早点战胜病毒
主要是爱心和文字结合,利用汉字取模和二进制的思想来输出文字,爱心主要借用了网上的代码,结合就是用了式子
找了改颜色,清屏,暂停来使显示更丰富多彩
代码
#include
#include
#include
//字体显示不同的颜色
int main (){
int ch[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; //判断0或者1
//武汉加油,中国加油,战胜病魔
int zong[13][33]={
{0},
{0,0x00,0x40,0x00,0x50,0x3F,0x48,0x00,0x48,0x00,0x40,0xFF,0xFE,0x00,0x40,0x04,0x40,
0x04,0x40,0x27,0x40,0x24,0x20,0x24,0x22,0x24,0x12,0x27,0x8A,0xF8,0x06,0x40,0x02},
{0,0x00,0x00,0x27,0xF8,0x12,0x08,0x12,0x08,0x82,0x08,0x41,0x10,0x49,0x10,0x09,0x10,
0x10,0xA0,0x10,0xA0,0xE0,0x40,0x20,0x40,0x20,0xA0,0x21,0x10,0x22,0x08,0x0C,0x06},
{0,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x7C,0xFE,0x44,0x12,0x44,0x12,0x44,0x12,0x44,
0x12,0x44,0x12,0x44,0x12,0x44,0x12,0x44,0x22,0x44,0x22,0x7C,0x4A,0x44,0x84,0x00},
{0,0x00,0x40,0x20,0x40,0x10,0x40,0x10,0x40,0x87,0xFC,0x44,0x44,0x44,0x44,0x14,0x44,
0x14,0x44,0x27,0xFC,0xE4,0x44,0x24,0x44,0x24,0x44,0x24,0x44,0x27,0xFC,0x04,0x04},
{0,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x21,0x08,
0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00},
{0,0x00,0x00,0x7F,0xFC,0x40,0x04,0x40,0x04,0x5F,0xF4,0x41,0x04,0x41,0x04,0x4F,0xE4,
0x41,0x04,0x41,0x44,0x41,0x24,0x5F,0xF4,0x40,0x04,0x40,0x04,0x7F,0xFC,0x40,0x04},
{0,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x7C,0xFE,0x44,0x12,0x44,0x12,0x44,0x12,0x44,
0x12,0x44,0x12,0x44,0x12,0x44,0x12,0x44,0x22,0x44,0x22,0x7C,0x4A,0x44,0x84,0x00},
{0,0x00,0x40,0x20,0x40,0x10,0x40,0x10,0x40,0x87,0xFC,0x44,0x44,0x44,0x44,0x14,0x44,
0x14,0x44,0x27,0xFC,0xE4,0x44,0x24,0x44,0x24,0x44,0x24,0x44,0x27,0xFC,0x04,0x04},
{0,0x10,0x20,0x10,0x28,0x10,0x24,0x1E,0x24,0x10,0x20,0x10,0x3E,0x11,0xE0,0x10,0x24,
0x7E,0x24,0x42,0x28,0x42,0x28,0x42,0x10,0x42,0x32,0x7E,0x4A,0x42,0x86,0x01,0x02},
{0,0x00,0x20,0x78,0x20,0x49,0x20,0x49,0x20,0x49,0xFC,0x79,0x20,0x4A,0x20,0x48,0x20,
0x48,0x20,0x79,0xFC,0x48,0x20,0x48,0x20,0x48,0x20,0x48,0x20,0x4B,0xFE,0x98,0x00},
{0,0x00,0x80,0x00,0x40,0x1F,0xFE,0x10,0x00,0x90,0x00,0x57,0xFC,0x50,0x40,0x10,0x40,
0x37,0xFC,0x54,0x44,0x94,0xA4,0x15,0x14,0x26,0x14,0x24,0x04,0x44,0x14,0x84,0x08},
{0,0x01,0x00,0x3F,0xF8,0x01,0x00,0x1F,0xF0,0x01,0x00,0x7F,0xFC,0x00,0x00,0x1F,0xF0,
0x12,0x10,0x11,0x10,0xFF,0xFE,0x22,0x10,0x21,0x10,0x3F,0xFC,0x00,0x10,0x00,0x60}
};
int a,i,j,k,l,m,n;
system("color 74");
Sleep(5000);
for(i=1;i<=6;i++){
for(j=1;j<=2;j++){
for(k=1;k<=32;k++){
if(k%2!=0){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY+FOREGROUND_RED);
if((k+1)/2==1||(k+1)/2==16){
for(a=1;a<=50;a++){
printf(" ");
}
}
else{
for(a=1;a<=10;a++){
printf(" ");
}
if((k+1)/2<=4){
if((k+1)/2==2){
printf(" ****** ****** ");
}
else if((k+1)/2==3){
printf(" ********** ********** ");
}
else if((k+1)/2==4){
printf(" ************* ************* ");
}
}
else if((k+1)/2<=7){
for(a=1;a<30;a++)
printf("*");
}
else if((k+1)/2<=14){
for(a=0;a<2*((k+1)/2-8+1)-1;a++)
printf(" ");
for(a=0;a<27-((k+1)/2-8)*4;a++)
printf("*");
for(a=0;a<2*((k+1)/2-8+1)-1;a++)
printf(" ");
}
else if((k+1)/2==15){
for(a=0;a<14;a++)
printf(" ");
printf("*");
for(a=0;a<14;a++)
printf(" ");
}
for(a=1;a<=10;a++){
printf(" ");
}
}
}
//一行
for(l=1;l<=8;l++){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), BACKGROUND_INTENSITY+FOREGROUND_BLUE);
if(zong[2*(i-1)+j][k]&ch[l-1])
printf("#");
else
printf(" ");
}
if(k%2==0){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY+FOREGROUND_RED);
if(k/2==1||k/2==16){
for(a=1;a<=55;a++){
printf(" ");
}
}
else{
for(a=1;a<=10;a++){
printf(" ");
}
if(k/2<=4){
if(k/2==2){
printf(" ****** ****** ");
}
else if(k/2==3){
printf(" ********** ********** ");
}
else if(k/2==4){
printf(" ************* ************* ");
}
}
else if(k/2<=7){
for(a=1;a<30;a++)
printf("*");
}
else if(k/2<=14){
for(a=0;a<2*(k/2-8+1)-1;a++)
printf(" ");
for(a=0;a<27-(k/2-8)*4;a++)
printf("*");
for(a=0;a<2*(k/2-8+1)-1;a++)
printf(" ");
}
else if(k/2==15){
for(a=0;a<14;a++)
printf(" ");
printf("*");
for(a=0;a<14;a++)
printf(" ");
}
for(a=1;a<=15;a++){
printf(" ");
}
}
printf("\n");
}
}
}
Sleep(2000);
system("color 74");
Sleep(500);
system("cls");
}
return 0;
}