运行效果
横版
*** ***** ***** *** ***
*** ********** ********** *** ***
*** ************* ************* *** ***
*** *************************** *** ***
*** *************************** *** ***
*** ************************* *** ***
*** *********************** *** ***
*** ********************* *** ***
*** ******************* *** ***
*** *************** *** ***
*** *********** *** ***
*** ***** ***************
*** * ***************
竖版
***
***
***
***
***
***
***
***
***
***
***
***
***
----------------------------------------------------------------------------------------------------
***** *****
********** **********
************* *************
***************************
***************************
*************************
***********************
*********************
*******************
***************
***********
*****
*
----------------------------------------------------------------------------------------------------
*** ***
*** ***
*** ***
*** ***
*** ***
*** ***
*** ***
*** ***
*** ***
*** ***
*** ***
***************
***************
变形(将代码的星号与空格互换就行)
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
****** *********** *********** *********** ********* ***
****** ********* ***** ********* ********* ***
****** ******** * ******** ********* ***
****** ******** ******** ********* ***
****** ******** ******** ********* ***
****** ********* ********* ********* ***
****** ********** ********** ********* ***
****** *********** *********** ********* ***
****** ************ ************ ********* ***
****** ************** ************** ********* ***
****** **************** **************** ********* ***
****** ******************* ******************* ***
****** ********************* ********************* ***
**********************************************************************
**********************************************************************
**********************************************************************
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