输出三角形
1, 打印如图类似的三角形
2,继续打印 打印出一个菱形(再来一个倒置三角) 本质找规律题 不喜
package com.cnm.cn;
import java.util.Scanner;
public class Add1 {
public static void main(String[] args) {
int lines;
while (true){
Scanner sc = new Scanner(System.in);
System.out.println("输入要几行");
lines = sc.nextInt();
if (lines%2!=0){break;}}
for (int line = 1; line <= lines; line++) {
for (int row = 1; row <= lines - line; row++) {
System.out.print(" ");
}
for (int rows = 1; rows <= 2 * line - 1; rows++) {
System.out.print("*");
}
System.out.println();
}
int lf=lines/2;
int lt=lf+1;
for (int lingline = 1; lingline <=lt; lingline++) {
for (int rowss=1;rowss<=lt-lingline;rowss++){
System.out.print(" ");
}
for(int rowst=1;rowst<=2*lingline-1;rowst++){
System.out.print("*");
}
System.out.println();
}
for(int rows1=1;rows1<=lf;rows1++){
for (int xingf1=1;xingf1<=rows1;xingf1++){
System.out.print(" ");
}
for (int xingf=1;xingf<=(lines-2*rows1);xingf++){
System.out.print("*");
}
System.out.println();
}
for(int rows1=1;rows1<=lines;rows1++){
for (int xingf1=1;xingf1<=rows1-1;xingf1++){
System.out.print(" ");
}
for (int xingf=1;xingf<=(2*lines-1)-2*(rows1-1);xingf++){
System.out.print("*");
}
System.out.println();}
}
}
// * 3 1 n/2+1-l 2l-1 1 13 13-2*n-1 2n-1-pow(2,n-1) 0 7 2n-1 0
// *** 2 3 n/2+1-l 2l-1 2 11 13-2*n-1 1 5 1
// ***** 1 5 3 9 13-2*n-1 2 3
//******* 0 7 4 7 13-2*n-1 4 7 3 2
// ***** 1 5 n/2 3 1 l-n/2-1 5 5 3 5 5 1 5 line-2*n-1 5 1 1 2n-1
// *** 2 3 3 2 6 6-3-1 6 3 3 6 3 2 3 6 3 2
// * 3 1 3 3 7 7 1 3 3 1 7 5 3
//
//*********** 1 9 2n-1 0
// ********* 2 1
// ******* 3 2
// ***** 4 3
// ***
// * 5 4
//******* 1 0
// ***** 2 1
// *** 3 2
// *