当前位置:网站首页>-元素之和-
-元素之和-
2022-08-03 05:10:00 【-JMY-】
题目描述
输入4*4方阵。
输入
输入4*4方阵,分别求两条对角线上元素之和。
输出
输出两条对角线上元素之和(如样例所示)。
样例输入
0 0 2 7 5 3 2 1 9 9 7 0 9 1 9 5
样例输出
15 27
参考代码
#include<bits/stdc++.h>
using namespace std;
int main(){
int a[5][5],b=0,c=0;
for(int i=1;i<=4;i++)
{
for(int j=1;j<=4;j++)
{
cin>>a[i][j];
}
}
for(int i=1;i<=4;i++)
{
b+=a[i][i];
c+=a[i][5-i];
}
cout<<b<<" "<<c;
return 0;
}
边栏推荐
猜你喜欢
随机推荐
力扣561. 数组拆分
breed Web刷机升级详细教材修正编译器固件说明_itkeji.top
Presto installation and deployment tutorial
在树莓派上搭建属于自己的网页(1)
数字孪生园区场景中的坐标知识
Pr第二次培训笔记
typescript46-函数之间的类型兼容性
阿里云对象存储oss私有桶生成链接
Object类与常用API
生活原则。
shell script loop statement
Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne
High availability, two locations and three centers
NotImplementedError: file structure not yet supported
web安全-sql注入漏洞
vim命令
User password encryption tool
typescript49-交叉类型
1054 求平均值 (20 分)
快速上手 Mockito 单元测试框架









