-->
当前位置:首页 > 题库

PROGRAMMING:Create a two-dimensional array and find the sum of the non edge elements and diagonal elements 2

Luz5年前 (2021-05-10)题库387
Input the order n of the matrix (n < = 14) from the keyboard, and the value of the elements in the matrix is equal to N times of the sum of the number of rows and columns in its position (the value of rows and columns starts counting from 0). First output the matrix (the width of each number is 4 and right aligned when displaying), and then calculate the output values of sum1 and sum2: sum1 is the sum of all non edge elements in the matrix, sum2 is the sum of one diagonal element of the matrix.
###Input format:
Enter the order n of the matrix from the keyboard (n < = 14)
###Output format:
First output the matrix (display each number with width of 4 and right alignment), and then calculate the output values of sum1 and sum2: sum1 is the sum of all non edge elements in the matrix, sum2 is the sum of one diagonal element of the matrix.
###Input example:
```in
three
```
###Output example:
```out
0 3 6
3 6 9
6 9 12
sum1=6
sum2=18
```







answer:If there is no answer, please comment