解题思路:顺序赋值
注意事项:
参考代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int s = sc.nextInt();
int a = 1;
int [][]arr= new int[s][s];
for (int i = 0; i <s; i++) {
for (int j = 0; j < i+1; j++) {
arr[i-j][j]=a;
a++;
}
}
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < s-i; j++) {
System.out.print(arr[i][j]+" ");
}
System.out.println();
}
}
}
0.0分
2 人评分
C二级辅导-分段函数 (C语言代码)浏览:869 |
三进制小数 (C++代码)(第11位大于1.5才能进位)浏览:1159 |
P1002 (C语言代码)浏览:992 |
C语言程序设计教程(第三版)课后习题9.3 (Java代码)浏览:981 |
【蟠桃记】 (C语言代码)浏览:659 |
【数组的距离】 (C语言代码)浏览:754 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:540 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:612 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:1470 |
震宇大神的杀毒软件 (C语言代码)浏览:1103 |