JAVA 循序排列

来源:百度知道 编辑:UC知道 时间:2024/06/27 13:43:57
1234
123
12
1
要求用for循环排列

public class test{
public static void main(String[] args) {
for(int i=4; i>=1;i--){
for(int j=1;j<=i;j++){
System.out.print(j+" ");
}
System.out.println();
}
}
}

for(int i=0;i<4;i++){
for(int j=1;j<=4-i;j++){
System.out.print(j);
}
}

class A{
public static void main(String[] args){
int a=new int[]{1,2,3,4};
int al=a.length;
for(int i=0;i<al;i++){
System.out.println(a[i]);
int al=al-1;
}
}
}