我在数组中创建了数组和存储值,然后尝试在右对齐的三角形中打印它们
System.out.println("Enter size ");
int input=console.nextInt();
int []array=new int[input];
for(int c=0; c<6; c++) {
//store values in array
array[c]=console.nextInt();
}
int a=1;
int b=6;
// to print spaces
for(int i=1; i<=6; i++) {
for(int j=1; j<=b; j++) {
System.out.print(" ");
}
System.out.print("");
b--;
}
// to print values of array with shape of triangle
for(int k=1;k<=6;k++ ) {
for(int m=0;m<a;m++ ) {
System.out.print(array[m]);
}
System.out.println();
}
break;
a++;
}
}