当前位置:网站首页>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);
}边栏推荐
- Global and Chinese market of glossometer 2022-2028: Research Report on technology, participants, trends, market size and share
- 2020.2.14
- 我管你什么okr还是kpi,PPT轻松交给你
- 老姜的特点
- Global and Chinese market of breast cancer imaging 2022-2028: Research Report on technology, participants, trends, market size and share
- Test the influence of influent swacth on the electromagnetic coil of quartz meter
- 不得不会的Oracle数据库知识点(二)
- A Kuan food rushed to the Shenzhen Stock Exchange: with annual sales of 1.1 billion, Hillhouse and Maotai CCB are shareholders
- Windos10 reinstallation system tutorial
- What is regression testing? Talk about regression testing in the eyes of Ali Test Engineers
猜你喜欢

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

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

Release and visualization of related data

On the day when 28K joined Huawei testing post, I cried: everything I have done in these five months is worth it

Beijing invites reporters and media

Unity elementary case notes of angry birds Siki college 1-6
![[error record] configure NDK header file path in Visual Studio (three header file paths of NDK | ASM header file path selection related to CPU architecture)](/img/44/aa4963d07d046deb2bc76eb59f8ff7.jpg)
[error record] configure NDK header file path in Visual Studio (three header file paths of NDK | ASM header file path selection related to CPU architecture)

Similarities and differences of text similarity between Jaccard and cosine

Sorry, Tencent I also refused

What is regression testing? Talk about regression testing in the eyes of Ali Test Engineers
随机推荐
Future源码一观-JUC系列
基于.NetCore开发博客项目 StarBlog - (14) 实现主题切换功能
For loop
【leetcode】374. Guess the size of the number
Subgraph isomorphism -subgraph isomorphism
Introduction to thread pool
Is the securities account opened by Caicai for individuals safe? Is there a routine
关于 uintptr_t和intptr_t 类型
功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
Why use get/set instead of exposing properties
不得不会的Oracle数据库知识点(一)
Unity elementary case notes of angry birds Siki college 1-6
Is it really possible that the monthly salary is 3K and the monthly salary is 15K?
Software testers, how can you quickly improve your testing skills? Ten minutes to teach you
Windos10 reinstallation system tutorial
system. Exit (0) and system exit(1)
A Kuan food rushed to the Shenzhen Stock Exchange: with annual sales of 1.1 billion, Hillhouse and Maotai CCB are shareholders
Similarities and differences of text similarity between Jaccard and cosine
What is the future of software testing industry? Listen to the test veterans' answers
不得不会的Oracle数据库知识点(二)