使用C语言绘制'I Love You'爱心

#include<stdio.h>
 #include<stdlib.h>
 #include<math.h>
 #include<windows.h>
 int main(){
     float x,y,value;
     int textIndex=0;
     char text[]="I Love You";
     int textLen=10;
     system("color 0c");
     for(y=1.5f;y>-1.5f;y-=0.1f){
         for(x=-1.5f;x<1.5f;x+=0.05f){
             value = pow((x * x + y * y - 1.0f), 3) - (x * x * y * y * y);
             if(value<=0.0f){
                 putchar(text[textIndex]);
                 textIndex=(textIndex+1)%textLen;
             }
             else{
                 putchar(' ');
             }
         }
         putchar('\n');
     }
     getchar();
     return 0;
 }


作者: yanleaf 发布时间: 2025-11-01 22:32:49 阅读数: 168 点赞数: 0 评论数:

评论区

备案期间,评论功能暂时关闭。