当前位置:网站首页>功能:求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);
}边栏推荐
- P3371 [template] single source shortest path (weakened version)
- Advanced C language - pointer 2 - knowledge points sorting
- SPI based on firmware library
- Generic tips
- Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools
- Iclr2022: how does AI recognize "things I haven't seen"?
- Is it really possible that the monthly salary is 3K and the monthly salary is 15K?
- [PHP basics] session basic knowledge, application case code and attack and defense
- Docking Alipay process [pay in person, QR code Payment]
- What is the GPM scheduler for go?
猜你喜欢

What is the Valentine's Day gift given by the operator to the product?

Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival
![[cloud native topic -48]:kubesphere cloud Governance - operation - overview of multi tenant concept](/img/b4/961b3b44e9ecbfd4bddd04318b663a.jpg)
[cloud native topic -48]:kubesphere cloud Governance - operation - overview of multi tenant concept

Analysis on the scale of China's smart health industry and prediction report on the investment trend of the 14th five year plan 2022-2028 Edition
![[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!](/img/28/fc05f2e8d53cf81fd061c799090022.jpg)
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!

NLP Chinese corpus project: large scale Chinese natural language processing corpus

Double efficiency. Six easy-to-use pychar plug-ins are recommended

Unity elementary case notes of angry birds Siki college 1-6

老姜的特点

Research Report on the scale prediction of China's municipal engineering industry and the prospect of the 14th five year plan 2022-2028
随机推荐
Detailed explanation of the relationship between Zhongtai, wechat and DDD
2022 Software Test Engineer skill list, please check
功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
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)
Kubedl hostnetwork: accelerating the efficiency of distributed training communication
[software testing] you haven't mastered these real interview questions of big companies?
Analysis: misunderstanding of choosing WMS warehouse management system
UTS | causal reasoning random intervention based on Reinforcement Learning
手机异步发送短信验证码解决方案-Celery+redis
Test the influence of influent swacth on the electromagnetic coil of quartz meter
NLP Chinese corpus project: large scale Chinese natural language processing corpus
Private project practice sharing populate joint query in mongoose makes the template unable to render - solve the error message: syntaxerror: unexpected token r in JSON at
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Idea set class header comments
Report on prospects and future investment recommendations of China's assisted reproductive industry, 2022-2028 Edition
How to be a professional software testing engineer? Listen to the byte five year old test
Global and Chinese markets for blood and liquid heating devices 2022-2028: Research Report on technology, participants, trends, market size and share
Research Report on the scale prediction of China's municipal engineering industry and the prospect of the 14th five year plan 2022-2028
Introduction to thread pool
ISBN number