当前位置:网站首页>-元素之和-
-元素之和-
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;
}
边栏推荐
- 13.< tag-动态规划和回文字串>lt.647. 回文子串 + lt.516.最长回文子序列
- odps的临时查询能在写sql的时候就给结果一个命名不?
- Exception (abnormal) and Error (error) difference analysis
- Pr第三次培训笔记
- 第四次培训
- ss-1.curl (cloud-provider-payment8001)
- Coordinate knowledge in digital twin campus scenarios
- 网络流媒体下载的 10 种方法(以下载 Echo 音乐为例)
- 反射注解基础
- Talking about GIS Data (5) - Geographic Coordinate System
猜你喜欢
【 Harmony OS 】 【 ano UI 】 lightweight data storage
【转】最小描述长度准则MDL(Minimun Description Length)
typescript44-对象之间的类兼容器
Install PostgreSQL on Windows
web安全-命令执行漏洞
在树莓派上搭建属于自己的网页(2)
Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne
js implements a bind function
如何不耍流氓的做运维之-SHELL脚本
2. 两数相加
随机推荐
第四次培训
HarmonyOS应用开发培训第二次作业
Djiango第三次培训
13.
lt.647. Palindromic substring + lt.516. Longest palindrome subsequence Junit
ss-5.consul服务端+生产者+消费者
斐讯K2路由编译Padavan华硕固件和心得
web安全-命令执行漏洞
【HMS core】【Ads Kit】Huawei Advertising——Overseas applications are tested in China. Official advertisements cannot be displayed
在树莓派上搭建属于自己的网页(2)
Pr第三次培训笔记
安装IIS服务(Internet信息服务(Internet Information Services,简写IIS,互联网信息服务)
[Harmony OS] [ARK UI] ETS context basic operations
typescript40-class类的保护修饰符
typescript43-类型兼容性说明
ModelArts第二次培训
1094 谷歌的招聘 (20 分)
Js学习笔记(四)
【特征选取】计算数据点曲率
建造者模式(Builder Pattern)