Pattern1:
public class Pattern1{
public static void main(String[] args) {
for(int i = 1;i<=6;i++){
for(int j = 1;j<=i;j++)
System.out.print(j);
System.out.println();
}
}
}
Pattern2:
public class Pattern2{
public static void main(String[] args) {
for(int i = 6;i>=1;i--){
for(int j = 1;j<=i;j++)
System.out.print(j);
System.out.println();
}
}
}
Pattern3 :
public class Pattern3{
public static void main(String[] args) {
for(int i = 1;i<=6;i++){
for(int j = 1; j<=(6-i);j++)
System.out.print(" ");
for(int j = i;j>=1;j--)
System.out.print(j);
System.out.println();
}
}
}
Pattern4:
public class Pattern4{
public static void main(String[] args) {
for(int i = 1;i<=6;i++){
for(int j = 1; j<=(i-1);j++)
System.out.print(" ");
for(int j = 1;j<=(7-i);j++)
System.out.print(j);
System.out.println();
}
}
}
我都测试过了。。。。希望能帮到你。。。。