当前位置:网站首页>Function: find the sum of the elements on the main and sub diagonal of the matrix with 5 rows and 5 columns. Note that the elements where the two diagonals intersect are added only once. For example,
Function: find the sum of the elements on the main and sub diagonal of the matrix with 5 rows and 5 columns. Note that the elements where the two diagonals intersect are added only once. For example,
2022-07-04 00:41:00 【CTGU-Yoghurt】
subject :

Code details :
#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);
}边栏推荐
- URL (data:image/png; Base64, ivborw0k... Use case
- The difference between objects and objects
- The super fully automated test learning materials sorted out after a long talk with a Tencent eight year old test all night! (full of dry goods
- 打印菱形图案
- 2-Redis架构设计到使用场景-四种部署运行模式(下)
- Alibaba test engineer with an annual salary of 500000 shares notes: a complete set of written tests of software testing
- Stock price forecast
- On the day when 28K joined Huawei testing post, I cried: everything I have done in these five months is worth it
- [GNN] hard core! This paper combs the classical graph network model
- NLP pre training technology development
猜你喜欢

What is the GPM scheduler for go?

A method to solve Bert long text matching

Sequence list and linked list

我管你什么okr还是kpi,PPT轻松交给你

Future source code view -juc series

Interview script of Software Test Engineer

MySQL winter vacation self-study 2022 12 (1)
![[NLP] text classification still stays at Bert? Duality is too strong than learning framework](/img/49/1ff6025bdb0445e5638c1451e0b267.jpg)
[NLP] text classification still stays at Bert? Duality is too strong than learning framework

Future源码一观-JUC系列

Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools
随机推荐
What does redis do? Redis often practices grammar every day
[C language] break and continue in switch statement
功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
NLP Chinese corpus project: large scale Chinese natural language processing corpus
Pair
What insurance products should be bought for the elderly?
[PHP basics] session basic knowledge, application case code and attack and defense
Entropy and full connection layer
删除所有值为y的元素。数组元素中的值和y的值由主函数通过键盘输入。
功能:求出菲波那契数列的前一项与后一项之比的极限的 近似值。例如:当误差为0.0001时,函数值为0.618056。
Data storage - interview questions
Introduction to thread pool
Att & CK actual combat series - red team actual combat - V
Swagger2 quick start and use
Employees' turnover intention is under the control of the company. After the dispute, the monitoring system developer quietly removed the relevant services
功能:求5行5列矩阵的主、副对角线上元素之和。注意, 两条对角线相交的元素只加一次。例如:主函数中给出的矩阵的两条对角线的和为45。
【leetcode】300. Longest increasing subsequence (dynamic programming, dichotomy)
Bodong medical sprint Hong Kong stocks: a 9-month loss of 200million Hillhouse and Philips are shareholders
Global and Chinese markets for coronary artery disease treatment devices 2022-2028: Research Report on technology, participants, trends, market size and share
Understanding of Radix