爱心代码咯----还缺女朋友吗?(4)

简介: 爱心代码咯----还缺女朋友吗?

爱心代码咯----还缺女朋友吗?(3)https://developer.aliyun.com/article/1544190

love组成的爱心

#include <stdio.h>
 
int main()
 
{
    int i, j, k, n = 0, x = 0, y = 50;
 
    //爱心的头部没有规律,所以直接打印
    printf("\n\n\n\n\n");
    printf("         lovelove                   lovelove\n");
    printf("       lovelovelove               lovelovelove\n");
    printf("     lovelovelovelove           lovelovelovelove\n");
    printf("   lovelovelovelovelove       lovelovelovelovelove\n");
    printf("  lovelovelovelovelovelo     lovelovelovelovelovelo\n");
    printf(" lovelovelovelovelovelove   lovelovelovelovelovelov\n");
    for (i = 0; i < 2; i++)
    {
        printf("lovelovelovelovelovelovelovelovelovelovelovelovelove\n");
 
    }
 
    for (i = 0; i < 5; i++)    //爱心的中间部分的上部分
    {
        y = 50;
        y = y - i * 2;
        n++;
        for (k = 0; k < n; k++)    //在每一行的起始位置先打印空格
        {
            printf(" ");
        }
        while (1)     //空格后面打印love,但是要注意love即使没打印完,也要换行
        {
            if (x < y)
            {
                printf("l");
                y--;
            }
            else
                break;
            if (x < y)
            {
                printf("o");
                y--;
            }
            else
                break; if (x < y)
            {
                printf("v");
                y--;
            }
                else
                break; if (x < y)
            {
                printf("e");
                y--;
            }
                else
                break;
        }
        printf("\n");
    }
 
 
    //最下面的部分,具体内容同上,没和上一部分放一起是因为从这行开始多两个空格
    for (i = 0, n = 3; i < 10; i++)
    {
        y = 37;
        y = y - i * 4;
        n++;
        for (k = 0; k < n; k++)
        {
            printf("  ");
        }
        while (1)
        {
            if (x < y)
            {
                printf("l");
                y--;
            }
            else
                break;
            if (x < y)
            {
                printf("o");
                y--;
            }
            else
                break; if (x < y)
            {
                printf("v");
                y--;
            }
                else
                break; if (x < y)
            {
                printf("e");
                y--;
            }
                else
                break;
        }
        printf("\n");
    }
 
    printf("\n\n\n\n\n\n\n\n\n\n\n\n");
    return 0;
}

指向爱心

#include<stdio.h>
#define V 4//设置心形放大倍数
#define list (4*V+3)//列数
#define row (3*V+3)//行数
void FindMainPoint(char line[row][list]);
void Connect(int r1, int r2, int l1, int l2, char line[row][list]);//r行l列
void Print(char line[row][list]);
void Finger(char point[17][20]);
int main(void)
{
    char line[row][list];
    char point[17][20];
    FindMainPoint(line);
    Print(line);
    printf("\n\n");
    Finger(point);
    return 0;
}
 
//找到关键点
void FindMainPoint(char line[row][list])
{
    int list_mid = (list + 1) / 2 - 1;
 
    int list_left = (list + 1) / 4 - 1;
 
    int list_left_right = list_left + 1;
 
    int list_right = list_mid + list_left + 1;
 
    int list_right_left = list_right - 1;
 
    int row_above = 1 - 1;
 
    int row_mid = row / 3 - 1;
 
    int row_mid_below = row_mid + 1;
 
    int row_below = row - 1;
 
    line[row_above][list_left] = '*';//(4,1)
    line[row_above][list_left_right] = '*';//(5,1)
    line[row_above][list_right] = '*';//(12,1)
    line[row_above][list_right_left] = '*';//(11,1)
 
    line[row_mid][0] = '*';//(1,4)
    line[row_mid][list_mid] = '*';//(8,4)
    line[row_mid][list - 1] = '*';//(15,4)
 
    line[row_mid_below][0] = '*';//(1,5)
    line[row_mid_below][list - 1] = '*';//(15,5)
 
    line[row_below][list_mid] = '*';//(8,12)
 
    Connect(row_mid, row_above, 0, list_left, line);//(1,4)&&(4,1)
    Connect(row_above, row_mid, list_left_right, list_mid, line);//(5,1)&&(8,4)
    Connect(row_mid, row_above, list_mid, list_right_left, line);//(8,4)&&(11,1)
    Connect(row_above, row_mid, list_right, list - 1, line);//(12,1)&&(15,4)
    Connect(row_mid_below, row_below, 0, list_mid, line);//(1,5)&&(8,12)
    Connect(row_below, row_mid_below, list_mid, list - 1, line);//(8,12)&&(15,5)
    return;
}
 
//连接关键点
void Connect(int r1, int r2, int l1, int l2, char line[row][list])
{
    int i, j;
    if (r1 > r2)
    {
        for (i = r1, j = l1; i >= r2; i--, j++)
        {
            line[i][j] = '*';
        }
    }
    else
    {
        for (i = r1, j = l1; i <= r2; i++, j++)
        {
            line[i][j] = '*';
        }
    }
    return;
}
 
//打印爱心
void Print(char line[row][list])
{
    int i, j;
    for (i = 0; i < row; i++)
    {
        printf("\t\t\t\t\t\t");//将图形尽量居中,改变大小后,自行修改
        for (j = 0; j < list; j++)
        {
            if (line[i][j] != '*')
            {
                printf(" ");
            }
            else
 
                printf("*");
        }
        printf("\n");
    }
}
 
//打印手指
void Finger(char point[17][20])
{
    int i, j;
    for (i = 0, j = 5; j <= 6; j++)
        point[i][j] = '*';//
    for (j = 4, i = 1; i <= 8; i++)
        point[i][j] = '*';//
    for (j = 7, i = 1; i <= 6; i++)
        point[i][j] = '*';//
    for (i = 4, j = 8; j <= 10; j++)
        point[i][j] = '*';//
    for (j = 11, i = 5; i <= 6; i++)
        point[i][j] = '*';//
    for (i = 5, j = 12; j <= 14; j++)
        point[i][j] = '*';//
    for (j = 15, i = 6; i <= 7; i++)
        point[i][j] = '*';//
    for (i = 6, j = 15; j <= 18; j++)
        point[i][j] = '*';
    for (j = 19, i = 7; i <= 11; i++)
        point[i][j] = '*';//
    for (j = 18, i = 12; i <= 13; i++)
        point[i][j] = '*';//
    for (j = 17, i = 14; i <= 15; i++)
        point[i][j] = '*';//
    for (i = 16, j = 6; j <= 16; j++)
        point[i][j] = '*';//
    for (i = 14, j = 7; j <= 15; j++)
        point[i][j] = '*';
    for (j = 7; j <= 15; j += 4)//
        for (i = 10; i <= 12; i++)
            point[i][j] = '*';
    for (j = 5, i = 14; i <= 15; i++)
        point[i][j] = '*';//
    for (j = 2, i = 10; i <= 11; i++)
        point[i][j] = '*';//
    for (j = 0, i = 7; i <= 8; i++)
        point[i][j] = '*';//
    for (i = 6, j = 1; j <= 2; j++)
        point[i][j] = '*';
    point[7][3] = '*';
    point[9][1] = '*';
    point[12][3] = '*';
    point[13][4] = '*';
    for (i = 0; i < 17; i++)
    {
        printf("\t\t\t\t\t\t  ");//将图形尽量居中,改变大小后,自行修改
        for (j = 0; j < 20; j++)
        {
            if (point[i][j] != '*')
            {
                printf(" ");
            }
            else
 
                printf("*");
        }
        printf("\n");
    }
}
相关文章
|
6月前
|
人工智能 小程序 算法
分享64个JavaGame源码总有一个是你想要的
分享64个JavaGame源码总有一个是你想要的
149 0
|
6月前
|
人工智能 Java 关系型数据库
分享66个JavaGame源码总有一个是你想要的
分享66个JavaGame源码总有一个是你想要的
233 0
|
5月前
|
C语言
爱心代码咯----还缺女朋友吗?(3)
爱心代码咯----还缺女朋友吗?
|
5月前
|
Python
爱心代码咯----还缺女朋友吗?(1)
爱心代码咯----还缺女朋友吗?
|
存储 算法 Linux
当我用几道题考了一遍做Linux驱动的同事......
当我用几道题考了一遍做Linux驱动的同事......
|
存储 Java
无聊小知识.04 以下代码会输出什么?
今天同事给我看了一段代码,然后这段简单的代码,我却陷入了沉思。
无聊小知识.04 以下代码会输出什么?
写C语言代码时,肯定值得你注意的点 ----2
写C语言代码时,肯定值得你注意的点 ----2
|
存储 C语言
写C语言代码时,肯定值得你注意的点 ----3
写C语言代码时,肯定值得你注意的点 ----3
【perl】老司机的再一次翻车:没有想到加了一句打印,会影响结果输出
【perl】老司机的再一次翻车:没有想到加了一句打印,会影响结果输出