当前位置:网站首页>[pointer] find the value of the largest element in the two-dimensional array
[pointer] find the value of the largest element in the two-dimensional array
2022-07-06 14:35:00 【|Light|】
requirement
Compile a function and program to find the value of the largest element in a two-dimensional array .( Use a pointer to achieve )
Code
int find_max(int a[4][4])
{
int *p=&a[0][0],max=a[0][0];
int i,j,k;
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
if(max < a[i][j])
max = a[i][j];
}
}
return max;
}
main function
int main()
{
int a[4][4],*p;
int i,j;
p=&a[0][0];
for(i=0;i<4;i++)
for(j=0;j<4;j++)
scanf("%d",p++);
printf("%d",find_max(a));
return 0;
}
test
Test input
1 2 3 5
6 5 4 3
7 9 8 3
120 3 32 23
Output
120
边栏推荐
- Windows platform mongodb database installation
- 指針:最大值、最小值和平均值
- Ucos-iii learning records (11) - task management
- c语言学习总结(上)(更新中)
- MySQL learning notes (stage 1)
- What language should I learn from zero foundation. Suggestions
- 5分钟掌握机器学习鸢尾花逻辑回归分类
- “人生若只如初见”——RISC-V
- 《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
- Statistics, 8th Edition, Jia Junping, Chapter 11 summary of knowledge points of univariate linear regression and answers to exercises after class
猜你喜欢
随机推荐
msf生成payload大全
JDBC read this article is enough
Bing Dwen Dwen official NFT blind box will be sold for about 626 yuan each; JD home programmer was sentenced for deleting the library and running away; Laravel 9 officially released | Sifu weekly
List and data frame of R language experiment III
《统计学》第八版贾俊平第十三章时间序列分析和预测知识点总结及课后习题答案
函数:求两个正数的最大公约数和最小公倍
Intranet information collection of Intranet penetration (I)
Chain team implementation (C language)
【指针】八进制转换为十进制
Fundamentals of digital circuit (V) arithmetic operation circuit
MSF generate payload Encyclopedia
Function: find the maximum common divisor and the minimum common multiple of two positive numbers
Attack and defense world misc practice area (GIF lift table ext3)
浙大版《C语言程序设计实验与习题指导(第3版)》题目集
指针 --按字符串相反次序输出其中的所有字符
函数:用牛顿迭代法求方程的根
How to earn the first pot of gold in CSDN (we are all creators)
《统计学》第八版贾俊平第七章知识点总结及课后习题答案
函数:计算字符串中大写字母的个数
【指针】求二维数组中最大元素的值