当前位置:网站首页>矩阵运算
矩阵运算
2022-06-22 08:02:00 【好好学吧867】
给定一个n×n的方阵,本题要求计算该矩阵除副对角线、最后一列和最后一行以外的所有元素之和。副对角线为从矩阵的右上角至左下角的连线。
输入格式:
输入第一行给出正整数n(1<n≤10);随后n行,每行给出n个整数,其间以空格分隔。
输出格式:
在一行中给出该矩阵除副对角线、最后一列和最后一行以外的所有元素之和。
输入样例:
4
2 3 4 1
5 6 1 1
7 1 8 1
1 1 1 1
输出样例:
35代码:
#include <stdio.h>
int main(){
int m=0,n=0,i=0,j=0;
scanf("%d",&n);
int a[n][n];
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
if(i!=n-1&&j!=n-1&&j!=n-1-i)
{
m=m+a[i][j];
}
}
}
printf("%d",m);
return 0;
} 边栏推荐
猜你喜欢

QT QtableView的使用示例
![[Oracle database] mammy tutorial day13 date function](/img/ca/90aaa682ec393b1531060377276ca6.png)
[Oracle database] mammy tutorial day13 date function

Use of keepalived high availability cluster

AutoCAD 2020.3中文版 (旧版本)

Energy and interference of waves

Detailed explanation of subnet mask

【Oracle 数据库】奶妈式教程 day14 转换函数

Maptalks: basic operation and wms/wmts map service loading

IP address planning

Upload your own library to pod
随机推荐
QT 控件增加双击事件
PostgreSQL common commands and SQL -- continuous update
Vue page caching problem solving (keep alive + page level routing guard + lifecycle activated)
Windchill API drops
(9)顺序队列与栈队列
MySQL index
dom4j+xpath解析xml文件
Runloop detail summary
(7) Bidirectional linked list
Excellent cases of data visualization
Thoughts on the construction of data analysis platform for small and medium-sized enterprises (I)
LR 2022 ultra detailed installation tutorial "latest"
KVO summary
(7)双向链表
Ugui text spacing textspacing
Applet vant UI implementation calls interface data and displays it
Characteristics of industrial Internet
Use js to download the current image
MySQL queries data within one hour
MySQL view