当前位置:网站首页>[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
边栏推荐
- 指针:最大值、最小值和平均值
- 指针 --按字符串相反次序输出其中的所有字符
- 【指针】求字符串的长度
- Low income from doing we media? 90% of people make mistakes in these three points
- Library management system
- Hackmyvm target series (1) -webmaster
- Binary search tree concept
- Statistics, 8th Edition, Jia Junping, Chapter 11 summary of knowledge points of univariate linear regression and answers to exercises after class
- 线程的实现方式总结
- Mathematical modeling idea of 2022 central China Cup
猜你喜欢
Detailed explanation of network foundation
Build domain environment (win)
《统计学》第八版贾俊平第二章课后习题及答案总结
关于交换a和b的值的四种方法
移植蜂鸟E203内核至达芬奇pro35T【集创芯来RISC-V杯】(一)
Record an API interface SQL injection practice
Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
Low income from doing we media? 90% of people make mistakes in these three points
《统计学》第八版贾俊平第九章分类数据分析知识点总结及课后习题答案
Web vulnerability - File Inclusion Vulnerability of file operation
随机推荐
内网渗透之内网信息收集(二)
Applet Web Capture -fiddler
Wu Enda's latest interview! Data centric reasons
函数:计算字符串中大写字母的个数
浙大版《C语言程序设计实验与习题指导(第3版)》题目集
Record an edu, SQL injection practice
【指针】删除字符串s中的所有空格
SQL injection
High concurrency programming series: 6 steps of JVM performance tuning and detailed explanation of key tuning parameters
Constants, variables, and operators of SystemVerilog usage
《统计学》第八版贾俊平第四章总结及课后习题答案
Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
Statistics 8th Edition Jia Junping Chapter 12 summary of knowledge points of multiple linear regression and answers to exercises after class
【指针】数组逆序重新存放后并输出
Lintcode logo queries the two nearest saplings
数字电路基础(五)算术运算电路
Xray and burp linkage mining
函数:求两个正数的最大公约数和最小公倍
Function: find the maximum common divisor and the minimum common multiple of two positive numbers
C language file operation