编写四个独立的程序,使用嵌套循环语句分别打印下面的图案
package zuoye;
import java.util.Scanner;
/**
* 孤鸿
* 题目:
* 2024/2/6 09:35
*/
public class exer18 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("Enter the number of lines: ");
int line=input.nextInt();
//图案 a
for (int i = 1; i <=line; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j+"\t");
}
System.out.println();
}
System.out.println("-------------图案 B-------------");
//图案 b
for (int i = line; i >0 ; i--) {
for (int j = 1; j <=i ; j++) {
System.out.print(j+"\t");
}
System.out.println();
}
System.out.println("-------------图案 C-------------");
//图案 c
int k=0;
for (int i =1; i <=line ; i++) {
for ( k = line; k > i; k--) {
System.out.print(" "+"\t");
}
for (int l = 0; l < k; l++) {
System.out.print((k-l)+"\t");
}
System.out.println();
}
System.out.println("-------------图案 D-------------");
int m=0;
for (int i = line; i >0; i--) {
for (int x = 0; x < line-i; x++) {
System.out.print("\t");
}
for ( int j = 1; j <= i; j++) {
System.out.print(j+"\t");
}
System.out.println();
}
}
}