C语言字符画字符闪画.docx
《C语言字符画字符闪画.docx》由会员分享,可在线阅读,更多相关《C语言字符画字符闪画.docx(50页珍藏版)》请在冰豆网上搜索。
C语言字符画字符闪画
星星图
#include
#include
#definexpow(fabs(i-25.0),2.0/3)
#defineypow(fabs(j/2.0-25.0),2.0/3)
#defineapow(20,2.0/3)
voidmain()
{
charch[51][51];
inti,j;
for(i=0;i<51;i++)
for(j=0;j<51;j++)
{
if(x+y<=a)
ch[i][j]='*';
else
ch[i][j]='';
}
for(i=0;i<51;i++)
for(j=0;j<51;j++)
{
if(j%51==0)
printf("\n");
printf("%c",ch[i][j]);
}
}
全星图
非二维数组实现
#include
#include
#definexpow(fabs(i-25.0),2.0/3)
#defineypow(fabs(j-25.0),2.0/3)
#defineapow(20,2.0/3)
voidmain()
{
inti,j;
for(i=0;i<51;i++)
for(j=0;j<51;j++)
{
if(j%51==0)printf("\n");
if(x+y<=a)
printf("*");
else
printf("");
}
}
二维数组实现
#include
#include
#definexpow(fabs(i-25.0),2.0/3)
#defineypow(fabs(j-25.0),2.0/3)
#defineapow(20,2.0/3)
voidmain()
{
charch[51][51];
inti,j;
for(i=0;i<51;i++)
for(j=0;j<51;j++)
{
if(x+y<=a)
ch[i][j]='*';
else
ch[i][j]='';
}
for(i=0;i<51;i++)
for(j=0;j<51;j++)
{
if(j%51==0)printf("\n");
printf("%c",ch[i][j]);
}
}
变种蝙蝠侠
#include
#include
#definexpow(fabs(i-25.0),2.0/3)
#defineypow(fabs(j-25.0),2.0/3)
#defineapow(20,2.0/3)
voidmain()
{
charch[51][51];
inti,j;
for(i=0;i<51;i++)
for(j=0;j<51;j++)
{
if(x+y<=a)
ch[i][j]='*';
else
ch[i][j]='';
}
for(i=0;i<51;i++)
for(j=0;j<51;j++)
{
if(j%51==0)
printf("\n");
if(ch[i][j]=='*')printf("%c",ch[i][j]);
elseprintf("%c",ch[i][j]);
}
}
太极图
二维数组实(着色)
#include
#include
voidsetcolor(unsignedshortForeColor,unsignedshortBackGroundColor)
{
HANDLEhCon=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon,(ForeColor%16)|(BackGroundColor%16*16));
}
voidmain()
{
chara[80][80];
inti,j;
for(i=0;i<80;i++)
for(j=0;j<80;j++)
{
a[i][j]='';
if((3*i-40)*(3*i-40)+(j-40)*(j-40)<=30*30)
{a[i][j]=2;
if(((j-40)*(j-40)+(3*i-25)*(3*i-25)<=15*15)||(j>=40))
if((j-40)*(j-40)+(3*i-55)*(3*i-55)>=15*15)
a[i][j]=1;
else
a[i][j]=2;
}
if((j-40)*(j-40)+(3*i-25)*(3*i-25)<=40)
a[i][j]=2;
if((j-40)*(j-40)+(3*i-55)*(3*i-55)<=40)
a[i][j]=1;
}
for(i=0;i<80;i++)
{printf("");
for(j=0;j<80;j++)
{
if(a[i][j]!
=2)
{
setcolor(7,0);printf("%c",a[i][j]);setcolor(7,0);
}
else
{
setcolor(10,0);printf("%c",a[i][j]);setcolor(7,0);
}
}
printf("\n");
}
}
非二维数组实现(未着色)
#include
voidmain()
{
inti,j;
for(i=0;i<80;i++)
for(j=0;j<80;j++)
{
if(j%80==0)printf("\n");
if((3*i-40)*(3*i-40)+(j-40)*(j-40)<=30*30)
{
if(((j-40)*(j-40)+(3*i-25)*(3*i-25)<=15*15)||(j>=40))
if((j-40)*(j-40)+(3*i-55)*(3*i-55)>=15*15)
if((j-40)*(j-40)+(3*i-25)*(3*i-25)<=40)
printf("%c",2);
else
printf("%c",1);
else
if((j-40)*(j-40)+(3*i-55)*(3*i-55)<=40)
printf("%c",1);
else
printf("%c",2);
else
if((j-40)*(j-40)+(3*i-55)*(3*i-55)<=40)
printf("%c",1);
else
printf("%c",2);
}
else
printf("");
}
}
帽子
#include
#include
#definep((i-25.0)*(i-25.0)+(j-25.0)*(j-25.0))
#definea20
voidmain()
{
charch[51][51];
inti,j;
for(i=0;i<51;i++)
for(j=0;j<51;j++)
{
if(p*p<=(3*a*p*i-4*a*i*i*i))
ch[i][j]='*';
else
ch[i][j]='';
}
for(i=0;i<51;i++)
for(j=0;j<51;j++)
{
if(j%51==0)
printf("\n");
printf("%c",ch[i][j]);
}
}
*******
*****************
***********************
***************************
********
三夜玫瑰
#include
#definex((i-25.0)*2)
#definey(j-25.0)
#definep((x*x+y*y))
#definea25
voidmain()
{
charch[51][51];
inti,j;
for(i=0;i<51;i++)
for(j=0;j<51;j++)
{
if(p*p<=(3*a*p*x-4*a*x*x*x))
ch[i][j]='*';
else
ch[i][j]='';
}
for(i=0;i<51;i++)
for(j=0;j<51;j++)
{
if(j%51==0)
printf("\n");
printf("%c",ch[i][j]);
}
}
*****
*******
*********
*********
*********
*********
*********
*******
*******
*****
*****
***
*
********************
****************************
****************************
****************************
**************************
********************
****
心型图
#include
#include
#definex((i-25.0))
#definey(j-25.0)
voidmain()
{
charch[51][51];
inti,j;
for(i=0;i<51;i++)
for(j=0;j<51;j++)
{
if(pow((x*x+y*y)-200,3.0)<=-30*x*x*x*y*y)
ch[i][j]='*';
else
ch[i][j]='0';
}
for(i=0;i<51;i++)
for(j=0;j<51;j++)
{
if(j%51==0)
printf("\n");
if(ch[i][j]=='*'&&ch[i][j]!
='*')printf("%c",ch[i][j]);
elseprintf("%c",ch[i][j]);
}
}
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
00000000000******0000000000000******0000000000000
000000000***********0000000***********00000000000
00000000*************00000*************0000000000
0000000***************000***************000000000
0000000****************0****************000000000
000000***********************************00000000
000000***********************************00000000
000000***********************************00000000
000000***********************************00000000
000000***********************************00000000
000000***********************************00000000
000000***********************************00000000
000000***********************************00000000
0000000*********************************000000000
0000000*********************************000000000
0000000*********************************000000000
00000000*******************************0000000000
00000000*******************************0000000000
000000000*****************************00000000000
000000000*****************************00000000000
0000000000***************************000000000000
00000000000*************************0000000000000
000000000000***********************00000000000000
000000000000***********************00000000000000
0000000000000*********************000000000000000
00000000000000*******************0000000000000000
0000000000000000***************000000000000000000
00000000000000000*************0000000000000000000
000000000000000000***********00000000000000000000
0000000000000000000*********000000000000000000000
000000000000000000000*****00000000000000000000000
0000000000000000000000***000000000000000000000000
00000000000000000000000*0000000000000000000000000
00000000000000000000000*0000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000
圆圈
二维数组实现
#include
#include