#include <stdio.h>

int main() { int i, j, n = 6; int heart[6][6] = { {0, 0, 1, 1, 0, 0}, {0, 1, 0, 0, 1, 0}, {1, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 1}, {0, 1, 0, 0, 1, 0}, {0, 0, 1, 1, 0, 0} };

for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
        if (heart[i][j] == 1)
            printf("*");
        else
            printf(" ");
    }
    printf("\n");
}

return 0;

}

运行以上代码,即可在控制台中输出一个爱心形状。

C语言绘制爱心图案代码示例

原文地址: https://www.cveoy.top/t/topic/pfuy 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录