当前位置:网站首页>-元素之和-
-元素之和-
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;
}
边栏推荐
- Common fluorescent dyes to modify a variety of groups and its excitation and emission wavelength data in the data
- 接口和抽象
- 集合框架知识
- Interface Test Framework Practice | Process Encapsulation and Test Case Design Based on Encrypted Interface
- 阿里云对象存储oss私有桶生成链接
- 第三次HarmonyOS培训
- 用户密码验证
- typescript43-类型兼容性说明
- 业务表解析-余额系统
- Redis6学习笔记
猜你喜欢

typescript44-对象之间的类兼容器

接口和抽象

快速上手 Mockito 单元测试框架

Redis常用命令

js实现一个 bind 函数

在树莓派上搭建属于自己的网页(2)

idea uses @Autowired annotation to explain the reasons and solutions

VSO Downloader Ultimate 5.0.1.45 中文多语免费版 在线视频下载工具

Fluorescent marker peptides FITC/AMC/FAM/Rhodamine TAMRA/Cy3 / Cy5 / Cy7 - Peptide

js implements a bind function
随机推荐
FileZilla 搭建ftp服务器
typescript43-类型兼容性说明
Apache DolphinScheduler版本2.0.5分布式集群的安装
MOSN 反向通道详解
【Harmony OS】【ARK UI】ets use startAbility or startAbilityForResult to invoke Ability
Js学习笔记(四)
typescript49-交叉类型
VR全景展打造专属元宇宙观展空间
信息编码、存储压缩与密码学
Build your own web page on the Raspberry Pi (2)
Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne
对角矩阵(diagonal matrix)
typescript39-class类的可见修饰符
Kaggle(四)Scikit-learn
Djiango第四次培训笔记
typescript44-对象之间的类兼容器
Common fluorescent dyes to modify a variety of groups and its excitation and emission wavelength data in the data
0.ROS常用命令
Super handy drawing tool is recommended
2. 两数相加