当前位置:网站首页>功能:求5行5列矩阵的主、副对角线上元素之和。注意, 两条对角线相交的元素只加一次。例如:主函数中给出的矩阵的两条对角线的和为45。
功能:求5行5列矩阵的主、副对角线上元素之和。注意, 两条对角线相交的元素只加一次。例如:主函数中给出的矩阵的两条对角线的和为45。
2022-07-04 00:34:00 【CTGU-Yoghurt】
题目:

代码详解:
#include <stdio.h>
#define M 5
int fun(int a[M][M])
{
/**********Program**********/
int i, j, sum = 0;
for (i = 0; i < M; i++)
{
sum += a[i][i];
sum += a[i][M - i - 1];
}
if (M & 1) sum -= a[M / 2][M / 2];
return sum;
/********** End **********/
}
int main()
{
int a[M][M] = { {1,3,5,7,9},{2,4,6,8,10},{2,3,4,5,6},{4,5,6,7,8},{1,3,4,5,6} };
int y;
y = fun(a);
printf("s=%d\n", y);
}边栏推荐
- 手机异步发送短信验证码解决方案-Celery+redis
- 2022 Software Test Engineer skill list, please check
- Att & CK actual combat series - red team actual combat - V
- [PHP basics] session basic knowledge, application case code and attack and defense
- STM32 GPIO CSDN creative punch in
- What is the difference between NFT, SFT and dnft? How to build NFT platform applications?
- I would like to ask how the top ten securities firms open accounts? Is it safe to open an account online?
- Entropy and full connection layer
- No qualifying bean of type ‘com. netflix. discovery. AbstractDiscoveryClientOptionalArgs<?>‘ available
- Global and Chinese market of glossometer 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
![Docking Alipay process [pay in person, QR code Payment]](/img/30/665580241020ee3adb872e725f0624.jpg)
Docking Alipay process [pay in person, QR code Payment]

Yyds dry goods inventory three JS source code interpretation - getobjectbyproperty method

Pytorch learning notes 5: model creation

Alibaba test engineer with an annual salary of 500000 shares notes: a complete set of written tests of software testing

Briefly understand the operation mode of developing NFT platform

Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools

Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?

Research Report on the scale prediction of China's municipal engineering industry and the prospect of the 14th five year plan 2022-2028

Shell script three swordsman sed
![P3371 [template] single source shortest path (weakened version)](/img/c5/bcb22e1ea573253005e56ebbd73bb7.jpg)
P3371 [template] single source shortest path (weakened version)
随机推荐
[cloud native topic -48]:kubesphere cloud Governance - operation - overview of multi tenant concept
Docking Alipay process [pay in person, QR code Payment]
STM32 GPIO CSDN creative punch in
It is worthy of "Alibaba internal software test interview notes" from beginning to end, all of which are essence
CSP window
The culprit of unrestrained consumption -- Summary
不得不会的Oracle数据库知识点(二)
Anomalies seen during the interview
Global and Chinese markets for instant saliva testing devices 2022-2028: Research Report on technology, participants, trends, market size and share
Speed up the energy Internet of things. What can low-power Internet of things technology represented by Zeta do?
Pair
Recommendation of knowledge base management system
What are the application fields of digital twins in industry?
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Development and application of fcitx functional plug-ins
What is the difference between NFT, SFT and dnft? How to build NFT platform applications?
P1339 [USACO09OCT]Heat Wave G
[software testing] you haven't mastered these real interview questions of big companies?
Unity elementary case notes of angry birds Siki college 1-6
Data mining vs Machine Learning: what is the difference between them? Which is more suitable for you to learn