当前位置:网站首页>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);
}边栏推荐
- Network layer - routing
- Alibaba test engineer with an annual salary of 500000 shares notes: a complete set of written tests of software testing
- 2022 Software Test Engineer skill list, please check
- What is the GPM scheduler for go?
- 我管你什么okr还是kpi,PPT轻松交给你
- ESP Arduino playing with peripherals (V) basic concept of interrupt and timer interrupt
- Arc 135 supplementary report
- How to be a professional software testing engineer? Listen to the byte five year old test
- Global and Chinese market of process beer equipment 2022-2028: Research Report on technology, participants, trends, market size and share
- 手机异步发送短信验证码解决方案-Celery+redis
猜你喜欢
![[prefix and notes] prefix and introduction and use](/img/a6/a75e287ac481559d8f733e6ca3e59c.jpg)
[prefix and notes] prefix and introduction and use
![[CSDN Q & A] experience and suggestions](/img/db/dff3173dda24ca5740729b54a81153.jpg)
[CSDN Q & A] experience and suggestions

NLP pre training technology development

The FISCO bcos console calls the contract and reports an error does not exist

Joint examination of six provinces 2017

It's OK to have hands-on 8 - project construction details 3-jenkins' parametric construction

A method to solve Bert long text matching

Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution

Windos10 reinstallation system tutorial

On covariance of array and wildcard of generic type
随机推荐
Employees' turnover intention is under the control of the company. After the dispute, the monitoring system developer quietly removed the relevant services
[PHP basics] session basic knowledge, application case code and attack and defense
Alibaba test engineer with an annual salary of 500000 shares notes: a complete set of written tests of software testing
Data mining vs Machine Learning: what is the difference between them? Which is more suitable for you to learn
Global and Chinese market of glossometer 2022-2028: Research Report on technology, participants, trends, market size and share
挖财帮个人开的证券账户安全吗?是不是有套路
A-Frame虚拟现实开发入门
Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools
不得不会的Oracle数据库知识点(四)
打印菱形图案
The FISCO bcos console calls the contract and reports an error does not exist
ITK learning notes (VII) the position of ITK rotation direction remains unchanged
数据库表外键的设计
The frost peel off the purple dragon scale, and the xiariba people will talk about database SQL optimization and the principle of indexing (primary / secondary / clustered / non clustered)
Network layer - routing
Axure resources and prototype tool Axure RP 9 download
Analysis: misunderstanding of choosing WMS warehouse management system
Pair
BBS forum recommendation
[CSDN Q & A] experience and suggestions