当前位置:网站首页>Practice 7-7 matrix operation (20 points)
Practice 7-7 matrix operation (20 points)
2022-07-22 18:54:00 【Now there is no forgotten thought】
practice 7-7 Matrix operations (20 branch )
Given a n×n Matrix of , This problem requires the calculation of the matrix divided by the sub diagonal 、 The sum of all elements except the last column and the last row . The sub diagonal is the line from the upper right corner of the matrix to the lower left corner .
Input format :
Enter the first line to give a positive integer n(1<n≤10); And then n That's ok , Each line gives n It's an integer , Separated by spaces .
Output format :
Give the matrix in one row divided by the sub diagonal 、 The sum of all elements except the last column and the last row .
sample input :
4
2 3 4 1
5 6 1 1
7 1 8 1
1 1 1 1
No blank lines at the end
sample output :
35
No blank lines at the end
#include <stdio.h>
int main()
{
int n,i,j;
scanf("%d",&n);
const int max=n;
int a[max][max],sum=0;
for (i=0;i<max;i++) {
for (j=0;j<max;j++) {
scanf("%d",&a[i][j]);
sum+=a[i][j];
}
}
int sum1=0,sum2=0,sum3=0;
for (i=0;i<max;i++) {
sum1+=a[n-1][i];
sum2+=a[i][n-1];
sum3+=a[i][n-1-i];
}
printf("%d",sum-sum1-sum2-sum3+a[n-1][n-1]+a[n-1][0]+a[0][n-1]);
}
边栏推荐
- Summary 20220118 (binary tree)
- Leetcode 2039. when the network is idle
- 1.Qt之打包发布程序 (NSIS);
- 【QT源代码复用】QDateTimeEdit的下拉按钮事件响应
- 1.QTableWidget插入按钮,灵活删除本行,一列显示行号
- MySQL statement execution order
- QT | modal dialog and modeless dialog qdialog
- 1.常量中有换行符Qt5-》vs的解决方案;2.同一份代码Qt和vs共同编译的问题和解决方案
- IP, subnet mask, gateway, IPS and IDS
- Leetcode 304. two dimensional area and retrieval - matrix immutable
猜你喜欢
随机推荐
Vlfeat, pydot configuration
02.依赖导致原则 - Dependence Inversion Principle
01.开闭原则 Open-Closed Principle
Summary 20220118 (binary tree)
华为手机锁定应用
Summary of various technical data -mysql
ECSHOP need to modify the folder and file of permission? The error directory cannot be written
App移动端测试【6】应用程序(apk)包管理与activity
练习7-4 找出不是两个数组共有的元素(C语言)
ps: 如何调出辅助线
1.常量中有换行符Qt5-》vs的解决方案;2.同一份代码Qt和vs共同编译的问题和解决方案
04. interface aggregation principle
Qt | 模态对话框和非模态对话框 QDialog
PTA 基础题7-28猴子选大王(简单方法)
Go memory model
LeetCode 653. 两数之和 IV - 输入 BST
PAT基础习题集7-26 单词长度(精简代码)
webFlux 中使用 openFeign 实现远程调用遇到的问题
bjyx
sql 语法中 join 的所有用法总结(简单例子)