生日快乐——爱心图

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define I 20
#define R 340
#define MAX_TIME 99999999

void draw_heart(int); 
void draw_wait(); 
void draw_color(); 

char color[] = "color ";
int len;
char font_color[] = {"023456789abcde"};
char back_color[] = {"000000000000b"};

int main()
{
    system("mode con cols=80 lines=40 ");
    system("title 向***致以最美好的祝福!");
    len = strlen(color);
    char data[200][60]={
                        {"祝你生日快乐!祝你生日快乐 !"},{"\nHappy birthday to you!\n"},

    {"今天是你成年的日子\n"},{"愿你想要的都得到\n"},{"得到的的都美好\n"},

    {"愿你勇敢无畏\n"},{"得偿所愿\n"},{"愿你有梦可依\n"},

    {"有人可爱\n"},{"愿你今后的旅程\n"},{"一路平安\n"},

    {"愿你考上理想的大学!\n"},{"金榜题名!\n"},{"未来可期!\n"},

    {"祝你生日快乐!\n"}
                    };
    int start = 9, end = 20;

    int sign = 0;
    int i,j;
    long times;    
    int wait = 15;
    for(sign = 0; sign < start; sign++){
        printf("\n%s",data[sign]);
        for(i = 0; i < wait; i++){
             draw_color(); 
            draw_wait();
        } 
        if(sign == 5)    wait /= 3;
    }    
    int colorsize = 10;
    printf("\n\n\n\n");
    draw_heart(0);
    for(; ; ){
        char cl[20];
        j = 0;
        for(i = j; i < strlen(font_color); i+=2){
            strcpy(cl, color);
            cl[len] = font_color[i];
            cl[len + 1] = '\0';
            system(cl);
            draw_wait();
        }
        j++;
        j %= 2;    
        srand((unsigned int)time(NULL));
        int k = rand() % strlen(back_color); 
        strcpy(cl, color);
        cl[len] = back_color[k];
        for(i = 0; i < strlen(font_color)/2; i++){
            srand((unsigned int)time(NULL));
            k = rand() % strlen(font_color); 
            cl[len + 1] = font_color[k];
            cl[len + 2] = '\0';
            system(cl);
            draw_wait();
        }    
        printf("\n%s",data[sign]);
        sign++;
        if(sign > end){
            break;
        }
    }
    while(1){
        draw_heart(1);
        printf("\n\n\n\n");
    }
    return 0;
}

void draw_color(){
    char cl[20]; 
    srand((unsigned int)time(NULL));
    int k = rand() % strlen(back_color); 
    strcpy(cl, color);
    cl[len] = back_color[k];
    srand((unsigned int)time(NULL));
    k = rand() % strlen(font_color);
    cl[len + 1] = font_color[k];
    cl[len + 2] = '\0';
    system(cl);
} 

void draw_heart(int wait){
    int i, j, e, a; 
    for(i=1,a=I;i<I/2;i++,a--){
        for(j=(int) ( I-sqrt(I*I-(a-i)*(a-i)) );j>0;j--)    printf(" ");
        for(e=1;e<=2*sqrt(I*I-(a-i)*(a-i));e++)    printf("\3");
        for(j=(int)( 2*( I-sqrt(I*I-(a-i)*(a-i)) ) );j>0;j--)    printf(" ");
        for(e=1;e<=2*sqrt(I*I-(a-i)*(a-i));e++)    printf("\3");
        printf("\n");
        if(wait && i % 2){
            draw_color();
            draw_wait();    
        }
    }
    for(i=1;i<80;i++){
        if(i==20){
            printf("=========祝*******,生日快乐!==========");
            i+=40;
        }
        printf("\3");
    }
    printf("\n");
    for(i=1;i<=R/2;i++){
        if(i%2||i%3)    continue;
        for(j=(int) ( R-sqrt(R*R-i*i) );j>0;j--)    printf(" ");
        for(e=1;e<=2*( sqrt(R*R-i*i) - (R-2*I) );e++)    printf("\3");
        printf("\n");
        if(wait){
            draw_color();
            draw_wait();    
        }
    }
}

void draw_wait(){
    int times;
    for(times=0;times<MAX_TIME;times++);
}

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值