当前位置:网站首页>[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
边栏推荐
- JVM memory model concept
- Statistics 8th Edition Jia Junping Chapter 14 summary of index knowledge points and answers to exercises after class
- 线程的实现方式总结
- 《统计学》第八版贾俊平第二章课后习题及答案总结
- Functions: Finding Roots of equations
- Intranet information collection of Intranet penetration (I)
- JDBC transactions, batch processing, and connection pooling (super detailed)
- Xray and Burp linked Mining
- 数字电路基础(五)算术运算电路
- 图书管理系统
猜你喜欢
Hackmyvm target series (1) -webmaster
Applet Web Capture -fiddler
Intranet information collection of Intranet penetration (I)
Record an edu, SQL injection practice
Circular queue (C language)
5 minutes to master machine learning iris logical regression classification
《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
Network layer - simple ARP disconnection
JDBC read this article is enough
《统计学》第八版贾俊平第八章假设检验知识点总结及课后习题答案
随机推荐
JDBC事务、批处理以及连接池(超详细)
内网渗透之内网信息收集(四)
【指针】求解最后留下的人
Library management system
Functions: Finding Roots of equations
《统计学》第八版贾俊平第十三章时间序列分析和预测知识点总结及课后习题答案
captcha-killer验证码识别插件
Proceedingjoinpoint API use
使用 flask_whooshalchemyplus jieba实现flask的全局搜索
Fundamentals of digital circuit (V) arithmetic operation circuit
Record an API interface SQL injection practice
Hackmyvm target series (1) -webmaster
《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
[paper reproduction] cyclegan (based on pytorch framework) {unfinished}
MSF generate payload Encyclopedia
servlet中 servlet context与 session与 request三个对象的常用方法和存放数据的作用域。
Intranet information collection of Intranet penetration (5)
The most popular colloquial system explains the base of numbers
Statistics 8th Edition Jia Junping Chapter 14 summary of index knowledge points and answers to exercises after class
XSS unexpected event