当前位置:网站首页>-元素之和-
-元素之和-
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;
}
边栏推荐
- Shell conditional statement judgment
- Exception(异常) 和 Error(错误)区别解析
- Business table analysis - balance system
- Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne
- 轨迹(形状)相似性判断与度量方法
- [Fine talk] Using native js to implement todolist
- Flask的简单介绍及使用方法简介
- VR全景展打造专属元宇宙观展空间
- 1054 求平均值 (20 分)
- 建造者模式(Builder Pattern)
猜你喜欢
Apache DolphinScheduler版本2.0.5分布式集群的安装
tag单调栈-单调栈预备知识-lt.739. 每日温度
Fluorescent marker peptides FITC/AMC/FAM/Rhodamine TAMRA/Cy3 / Cy5 / Cy7 - Peptide
Common lipophilic cell membrane dyes DiO, Dil, DiR, Did spectrograms and experimental procedures
Harmony OS Date ano UI 】 【 】 the basic operation
Djiango第四次培训笔记
接口和抽象
VSO Downloader Ultimate 5.0.1.45 中文多语免费版 在线视频下载工具
Object类与常用API
Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne
随机推荐
junit总结
odps的临时查询能在写sql的时候就给结果一个命名不?
Redis常用命令
集合框架知识
GIS数据漫谈(五)— 地理坐标系统
web安全-PHP反序列化漏洞
shell script loop statement
生活原则。
Tributyl-mercaptophosphane "tBuBrettPhos Pd(allyl)" OTf), 1798782-17-8
用户密码验证
如何不耍流氓的做运维之-SHELL脚本
网络流媒体下载的 10 种方法(以下载 Echo 音乐为例)
MOSN 反向通道详解
阿里云对象存储oss私有桶生成链接
Create a tree structure
在树莓派上搭建属于自己的网页(2)
flask 面试题 问题
Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne
Modelarts第一次培训
OptionError: ‘Pattern matched multiple keys‘