栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

表白代码(输出 I 爱 U)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

表白代码(输出 I 爱 U)

表白代码(输出 I 爱 U)
  • 运行效果
    • 横版
    • 竖版
    • 变形(将代码的星号与空格互换就行)
  • C
  • Java
  • Python

运行效果 横版
                                                                      
      ***           *****           *****           ***         ***   
      ***         **********     **********         ***         ***   
      ***        ************* *************        ***         ***   
      ***        ***************************        ***         ***   
      ***        ***************************        ***         ***   
      ***         *************************         ***         ***   
      ***          ***********************          ***         ***   
      ***           *********************           ***         ***   
      ***            *******************            ***         ***   
      ***              ***************              ***         ***   
      ***                ***********                ***         ***   
      ***                   *****                   ***************   
      ***                     *                     ***************   

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

C
#include 
#include 

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

横版

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()
    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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/490365.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号