520 ,各位节日快乐

作者: cnpll | 来源:发表于2019-05-19 23:40 被阅读0次

    520送你们几行代码

    希望各位节日快乐!!!

    C语言

    运行结果
    上代码
    #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;
    
                    }
    
                }
    
                    else
    
                        printf(" ");
    
                        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;
    
                        }
    
                    }
    
                        else
    
                            printf(" ");
    
                }
    
                    printf("\n");
    
            }
    
                Sleep(1000);
    
                system("cls");
    
                
    
        }
    
    }
    



    Python

    运行结果
    上代码
    import turtle as t
    # 定义一个曲线绘制函数
    def DegreeCurve(n, r, d=1):
        for i in range(n):
            t.left(d)
            t.circle(r, abs(d))
    # 初始位置设定
    s = 0.2 # size
    t.setup(450*5*s, 750*5*s)
    t.pencolor("black")
    t.fillcolor("red")
    t.speed(100)
    t.penup()
    t.goto(0, 900*s)
    t.pendown()
    # 绘制花朵形状
    t.begin_fill()
    t.circle(200*s,30)
    DegreeCurve(60, 50*s)
    t.circle(200*s,30)
    DegreeCurve(4, 100*s)
    t.circle(200*s,50)
    DegreeCurve(50, 50*s)
    t.circle(350*s,65)
    DegreeCurve(40, 70*s)
    t.circle(150*s,50)
    DegreeCurve(20, 50*s, -1)
    t.circle(400*s,60)
    DegreeCurve(18, 50*s)
    t.fd(250*s)
    t.right(150)
    t.circle(-500*s,12)
    t.left(140)
    t.circle(550*s,110)
    t.left(27)
    t.circle(650*s,100)
    t.left(130)
    t.circle(-300*s,20)
    t.right(123)
    t.circle(220*s,57)
    t.end_fill()
    # 绘制花枝形状
    t.left(120)
    t.fd(280*s)
    t.left(115)
    t.circle(300*s,33)
    t.left(180)
    t.circle(-300*s,33)
    DegreeCurve(70, 225*s, -1)
    t.circle(350*s,104)
    t.left(90)
    t.circle(200*s,105)
    t.circle(-500*s,63)
    t.penup()
    t.goto(170*s,-30*s)
    t.pendown()
    t.left(160)
    DegreeCurve(20, 2500*s)
    DegreeCurve(220, 250*s, -1)
    # 绘制一个绿色叶子
    t.fillcolor('green')
    t.penup()
    t.goto(670*s,-180*s)
    t.pendown()
    t.right(140)
    t.begin_fill()
    t.circle(300*s,120)
    t.left(60)
    t.circle(300*s,120)
    t.end_fill()
    t.penup()
    t.goto(180*s,-550*s)
    t.pendown()
    t.right(85)
    t.circle(600*s,40)
    # 绘制另一个绿色叶子
    t.penup()
    t.goto(-150*s,-1000*s)
    t.pendown()
    t.begin_fill()
    t.rt(120)
    t.circle(300*s,115)
    t.left(75)
    t.circle(300*s,100)
    t.end_fill()
    t.penup()
    t.goto(430*s,-1070*s)
    t.pendown()
    t.right(30)
    t.circle(-600*s,35)
    t.done()
    
    


    HTML 、JS

    运行结果
    上代码
    <!DOCTYPE html>
    <html>
    <head>
    <title>3D玫瑰
    </title>
    <meta charset="utf-8">
    </head>
    <body>
    <canvas id="c" height="500" width="500"></canvas>
    <script>
        var b = document.body;
        var c = document.getElementsByTagName('canvas')[0];
        var a = c.getContext('2d');
        document.body.clientWidth;
    </script>
    <script>
    // start of submission //
    with(m=Math)C=cos,S=sin,P=pow,R=random;c.width=c.height=f=500;h=-250;function p(a,b,c){if(c>60)return[S(a*7)*(13+5/(.2+P(b*4,4)))-S(b)*50,b*f+50,625+C(a*7)*(13+5/(.2+P(b*4,4)))+b*400,a*1-b/2,a];A=a*2-1;B=b*2-1;if(A*A+B*B<1){if(c>37){n=(j=c&1)?6:4;o=.5/(a+.01)+C(b*125)*3-a*300;w=b*h;return[o*C(n)+w*S(n)+j*610-390,o*S(n)-w*C(n)+550-j*350,1180+C(B+A)*99-j*300,.4-a*.1+P(1-B*B,-h*6)*.15-a*b*.4+C(a+b)/5+P(C((o*(a+1)+(B>0?w:-w))/25),30)*.1*(1-B*B),o/1e3+.7-o*w*3e-6]}if(c>32){c=c*1.16-.15;o=a*45-20;w=b*b*h;z=o*S(c)+w*C(c)+620;return[o*C(c)-w*S(c),28+C(B*.5)*99-b*b*b*60-z/2-h,z,(b*b*.3+P((1-(A*A)),7)*.15+.3)*b,b*.7]}o=A*(2-b)*(80-c*2);w=99-C(A)*120-C(b)*(-h-c*4.9)+C(P(1-b,7))*50+c*2;z=o*S(c)+w*C(c)+700;return[o*C(c)-w*S(c),B*99-C(P(b, 7))*50-c/3-z/1.35+450,z,(1-b/1.2)*.9+a*.1, P((1-b),20)/4+.05]}}setInterval('for(i=0;i<1e4;i++)if(s=p(R(),R(),i%46/.74)){z=s[2];x=~~(s[0]*f/z-h);y=~~(s[1]*f/z-h);if(!m[q=y*f+x]|m[q]>z)m[q]=z,a.fillStyle="rgb("+~(s[3]*h)+","+~(s[4]*h)+","+~(s[3]*s[3]*-80)+")",a.fillRect(x,y,1,1)}',0)
    // end of submission //
    </script>
    </body>
    </html>
    

    部分内容来源于朋友。

    相关文章

      网友评论

        本文标题:520 ,各位节日快乐

        本文链接:https://www.haomeiwen.com/subject/bliczqtx.html