之前自己写了一个不行是畸形的,又找了一个,大家可以写个自己的女朋友当作一个小乐趣,不过代码有好多地方都看不懂,求大神给解析一下!public class zj{
char xin=3;
int HighLove(int wide){
int i =0,j=0,k=0,t=0,m=0,n=0,count=1;
m=(wide-4)/2;
do{
count++;
m-=4;
}while(m>4);
if((wide-4)%2==0){
n=2+4*(count-1);
m--;
}
else{
n=1+4*(count-1);
}
for(i=0;i<count;i++){
for(j=(count-i)*2;j>0;j--){
System.out.print(" ");
}
for(k=0;k<m;k++){
System.out.print(xin);
}
for(t=0;t<n;t++){
System.out.print(" ");
}
for(k=0;k<m;k++){
System.out.print(xin);
}
m+=4;
n-=4;
System.out.print("\n");
}
return 0;
}
int LowLove(int wide){
int i=0,j=0,k=0;
int high = 1,tmp=wide;
do{
high++;
tmp-=4;
}while(tmp>4);
//high-=1;
for(i=1;i<high;i++){
for(j=0;j<2*i;j++){
System.out.print(" ");
}
for(k=wide-4*i;k>0;k--){
System.out.print(xin);
}
System.out.print("\n");
}
return 0;
}
public static void main(String[] args){
int wide = 35;
zj heart = new zj();
heart.HighLove(wide);
heart.LowLove(wide);
}
}
|
|