表白代码(输出 I 爱 U)

运行效果

横版

                                                                      
      ***           *****           *****           ***         ***   
      ***         **********     **********         ***         ***   
      ***        ************* *************        ***         ***   
      ***        ***************************        ***         ***   
      ***        ***************************        ***         ***   
      ***         *************************         ***         ***   
      ***          ***********************          ***         ***   
      ***           *********************           ***         ***   
      ***            *******************            ***         ***   
      ***              ***************              ***         ***   
      ***                ***********                ***         ***   
      ***                   *****                   ***************   
      ***                     *                     ***************   

竖版

                                                                      
      ***                                                             
      ***                                                             
      ***                                                             
      ***                                                             
      ***                                                             
      ***                                                             
      ***                                                             
      ***                                                             
      ***                                                             
      ***                                                             
      ***                                                             
      ***                                                             
      ***                                                             
                                                                                                                                   
----------------------------------------------------------------------------------------------------
                                                       
                                                       
     *****           *****                             
   **********     **********                           
  ************* *************                          
  ***************************                          
  ***************************                          
   *************************                           
    ***********************                            
     *********************                             
      *******************                              
        ***************                                
          ***********                                  
             *****                                     
               *                                       
                                                       
----------------------------------------------------------------------------------------------------
                                                  
                                                  
   ***         ***                                
   ***         ***                                
   ***         ***                                
   ***         ***                                
   ***         ***                                
   ***         ***                                
   ***         ***                                
   ***         ***                                
   ***         ***                                
   ***         ***                                
   ***         ***                                
   ***************                                
   ***************                                
                                                  

变形(将代码的星号与空格互换就行)


**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
******   ***********     ***********     ***********   *********   ***
******   *********          *****          *********   *********   ***
******   ********             *             ********   *********   ***
******   ********                           ********   *********   ***
******   ********                           ********   *********   ***
******   *********                         *********   *********   ***
******   **********                       **********   *********   ***
******   ***********                     ***********   *********   ***
******   ************                   ************   *********   ***
******   **************               **************   *********   ***
******   ****************           ****************   *********   ***
******   *******************     *******************               ***
******   ********************* *********************               ***
**********************************************************************
**********************************************************************
**********************************************************************

C

#include <stdio.h>
#include <math.h>

int main()
{
	float x,y,z;
	for(y=2.5; y>=-1.6; y-=0.2){
		for(x=-3; x<=4; x+=0.1){
			((pow((x*x+y*y-1),3)<=3.6*x*x*y*y*y) || (x>-2.4 && x<-2.1 && y<1.5 && y>-1) || (((x<2.5&x>2.2)||(x>3.4&&x<3.7))&&y>-1&&y<1.5) || (y>-1&&y<-0.6&&x<3.7&&x>2.2)) ? printf("*") : printf(" ");
		}
		printf("\n");
	}
    return 0;
}

Java

package com.bao;

public class Main {
    public static void main(String[] args) {
        for(double y=2.5; y>=-1.6; y-=0.2){
            for(double x=-3; x<=4; x+=0.1){
                if (((Math.pow((x * x + y * y - 1), 3) <= 3.6 * x * x * y * y * y) || (x > -2.4 && x < -2.1 && y < 1.5 && y > -1) || (((x < 2.5 & x > 2.2) || (x > 3.4 && x < 3.7)) && y > -1 && y < 1.5) || (y > -1 && y < -0.6 && x < 3.7 && x > 2.2))) {
                    System.out.print("*");
                } else {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}

Python

横版

import time
y = 2.5
while y>=-1.6:
    x = -3.0
    while x<=4.0:
        if (x*x+y*y-1)**3<=3.6*x*x*y*y*y or (x>-2.4 and x<-2.1 and y<1.5 and y>-1) or (((x<2.5 and x>2.2)or(x>3.4 and x<3.7)) and y>-1 and y<1.5) or (y>-1 and y<-0.6 and x<3.7 and x>2.2):
            print('*',end="")
        else:
            print(' ',end="")
        x += 0.1
    print()
    time.sleep(0.25)
    y -= 0.2

竖版

y = 2.5
while y>=-1.6:
    x = -3
    while x<=4.0:
        if x>-2.4 and x<-2.1 and y<1.5 and y>-1:
            print('*',end="")
        else:
            print(' ',end="")
        x += 0.1
    print()
    y -= 0.2

print('-'*100)

y = 2.5
while y>=-1.6:
    x = -1.5
    while x<=4.0:
        if (x*x+y*y-1)**3 <= 3.6*x*x*y*y*y:
            print('*',end="")
        else:
            print(' ',end="")
        x += 0.1
    print()
    y -= 0.2

print('-'*100)

y = 2.5
while y>=-1.6:
    x = -1.0
    while x<=4.0:
        if (((x<-0.5 and x>-0.8)or(x>0.4 and x<0.7)) and y>-1 and y<1.5) or (y>-1 and y<-0.6 and x<0.7 and x>-0.8):
            print('*',end="")
        else:
            print(' ',end="")
        x += 0.1
    print()
    y -= 0.2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值