当前位置:网站首页>功能:求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);
}边栏推荐
- Global and Chinese markets for blood and liquid heating devices 2022-2028: Research Report on technology, participants, trends, market size and share
- Pytest unit test framework: simple and easy to use parameterization and multiple operation modes
- P1339 [USACO09OCT]Heat Wave G
- Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools
- Detailed explanation of the relationship between Zhongtai, wechat and DDD
- Regular expressions and text processors for shell programming
- [PHP basics] session basic knowledge, application case code and attack and defense
- 挖财帮个人开的证券账户安全吗?是不是有套路
- 2020.2.14
- Briefly understand the operation mode of developing NFT platform
猜你喜欢

Reading notes on how programs run
![[GNN] hard core! This paper combs the classical graph network model](/img/a7/2140744ebad9f1dc0a609254cc618e.jpg)
[GNN] hard core! This paper combs the classical graph network model

SPI based on firmware library

A method to solve Bert long text matching

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

Pytest unit test framework: simple and easy to use parameterization and multiple operation modes

What is the GPM scheduler for go?

Zipper table in data warehouse (compressed storage)

Solve the problem that the kaggle account registration does not display the verification code

Is user authentication really simple
随机推荐
Severity code description the project file line prohibits the display of status error c4996 fopen ('fscanf ', StrCmp): this function or variable may be unsafe The most comprehensive solution
Pytest unit test framework: simple and easy to use parameterization and multiple operation modes
Report on prospects and future investment recommendations of China's assisted reproductive industry, 2022-2028 Edition
What is the Valentine's Day gift given by the operator to the product?
功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
[complimentary ppt] kubemeet Chengdu review: make the delivery and management of cloud native applications easier!
Unity elementary case notes of angry birds Siki college 1-6
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)
[PHP basics] session basic knowledge, application case code and attack and defense
Several ways to set up a blog locally [attach relevant software download links]
[GNN] hard core! This paper combs the classical graph network model
[C language] break and continue in switch statement
MySQL winter vacation self-study 2022 12 (1)
BBS forum recommendation
Development and application of fcitx functional plug-ins
system. Exit (0) and system exit(1)
不得不会的Oracle数据库知识点(三)
How to be a professional software testing engineer? Listen to the byte five year old test
Pair
国元证券开户是真的安全可靠吗