当前位置:网站首页>-元素之和-
-元素之和-
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;
}
边栏推荐
猜你喜欢
[Harmony OS] [ARK UI] ETS context basic operations
Secondary development of WinForm controls
Coordinate knowledge in digital twin campus scenarios
typescript39-class类的可见修饰符
typescript44-对象之间的类兼容器
传说中可“免费白拿”的无线路由器 - 斐讯 K2 最简单刷 breed 与第三方固件教程
typescript43-类型兼容性说明
breed Web刷机升级详细教材修正编译器固件说明_itkeji.top
BIOTIN ALKYNE CAS: 773888-45-2 Price, Supplier
Pr第三次培训笔记
随机推荐
typescript47-函数之间的类型兼容性
内部类、static关键字、final
Installation of Apache DolphinScheduler version 2.0.5 distributed cluster
Gradle的安装配置
【特征选取】计算数据点曲率
HarmonyOS应用开发培训第二次作业
High availability, two locations and three centers
ss-4.2 多个eureka集群案例
shell script loop statement
Kaggle(四)Scikit-learn
0.ROS常用命令
安装IIS服务(Internet信息服务(Internet Information Services,简写IIS,互联网信息服务)
Modelarts第一次培训
反射注解基础
Detailed explanation of MOSN reverse channel
IO process thread -> thread -> day5
[Harmony OS] [ArkUI] ets development graphics and animation drawing
力扣561. 数组拆分
Business table analysis - balance system
Shell conditional statement judgment