用c語言,製做一個心形彩色告白圖案(附源碼)

今天咱們來一個好玩的,用c語言,製做一個心形彩色告白圖案。windows

送給c語言初學者ide

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

 心形彩色代碼代碼:blog

#include<stdio.h> #include<math.h> #include<windows.h> #include<time.h> 

#define u 0.1 

#define v 0.053 

void setcolor(unsigned short forecolor,unsigned short backgroundcolor) 

{ 

    handle hcon=getstdhandle(std_output_handle); 

    setconsoletextattribute(hcon,(forecolor%16)|(backgroundcolor%16*16)); 

} 

int main() 

{ int i,s=0,t,a=10,b=11,c=12,d=13,e=14; int z[] = {32,32,206,210,207,178,187,182,196,227,33,32,32}; float x,y; 

    srand(time(null)); for(y=1.3;y>=-1.1;y-=u) 

    { for(x=-2;x<1.4;x+=v) 

        { if((((x*x+y*y-1)*(x*x+y*y-1)*(x*x+y*y-1)-x*x*y*y*y)<=0)) 

            { if(y>=1.3-10*u||y<=1.3-11*u) 

                { 

                s++; if(s%4==1){setcolor(a,0);printf("l");} if(s%4==2){setcolor(e,0);printf("o");} if(s%4==3){setcolor(c,0);printf("v");} if(s%4==0){setcolor(d,0);printf("e");} 

                } else{   for(i = 0;i < 42;i++) 

                    {   if(i<=14||i>=28) 

                        { 

                            s++; if(s%4==1){setcolor(a,0);printf("l");} if(s%4==2){setcolor(e,0);printf("o");} if(s%4==3){setcolor(c,0);printf("v");} if(s%4==0){setcolor(d,0);printf("e");} 

                        } else{ 

                            setcolor(b,0); 

                            printf("%c", z[i-15]); 

                            sleep(50); 

                        } 

                    } break; 

                } 

            } elseprintf(" "); 

                    sleep(1); 

        } 

    printf("\n"); 

    } 

    printf("按任意鍵繼續!"); 

    getchar();   while(1) 

    { 

                system("cls"); 

            t=a;a=b;b=c;c=d;d=e;e=t; for(y=1.3;y>=-1.1;y-=u) 

        { for(x=-2;x<1.4;x+=v) 

            { if((((x*x+y*y-1)*(x*x+y*y-1)*(x*x+y*y-1)-x*x*y*y*y)<=0)) 

                { if(y>=1.3-10*u||y<=1.3-11*u) 

                    { 

                    s++; if(s%4==1){setcolor(a,0);printf("l");} if(s%4==2){setcolor(b,0);printf("o");} if(s%4==3){setcolor(c,0);printf("v");} if(s%4==0){setcolor(d,0);printf("e");} 

                    } else{   for(i = 0;i < 42;i++) 

                        {   if(i<=14||i>=28) 

                            { 

                                s++; if(s%4==1){setcolor(a,0);printf("l");} if(s%4==2){setcolor(b,0);printf("o");} if(s%4==3){setcolor(c,0);printf("v");} if(s%4==0){setcolor(d,0);printf("e");} 

                            } else{ 

                                setcolor(e,0); 

                                printf("%c", z[i-15]); 

                            } 

                        } break; 

                    } 

                } elseprintf(" "); 

            } 

                printf("\n"); 

        } 

            sleep(1000); 

            system("cls");

    } 

}
相關文章
相關標籤/搜索