当前位置:网站首页>【指针】求二维数组中最大元素的值
【指针】求二维数组中最大元素的值
2022-07-06 09:24:00 【|光|】
要求
编一个函数编写程序求二维数组中最大元素的值。(用指针实现)
代码
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函数
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;
}
测试
测试输入
1 2 3 5
6 5 4 3
7 9 8 3
120 3 32 23
输出
120
边栏推荐
- 浙大版《C语言程序设计实验与习题指导(第3版)》题目集
- 链队实现(C语言)
- sqqyw(淡然点图标系统)漏洞复现和74cms漏洞复现
- [paper reproduction] cyclegan (based on pytorch framework) {unfinished}
- Fire! One day transferred to go engineer, not fire handstand sing Conquest (in serial)
- Hackmyvm target series (4) -vulny
- AQS details
- 小程序web抓包-fiddler
- Intranet information collection of Intranet penetration (5)
- SQL注入
猜你喜欢

Statistics, 8th Edition, Jia Junping, Chapter 6 Summary of knowledge points of statistics and sampling distribution and answers to exercises after class

Applet Web Capture -fiddler

Network layer - simple ARP disconnection

Harmonyos JS demo application development

Solutions to common problems in database development such as MySQL

Intranet information collection of Intranet penetration (5)

记一次,修改密码逻辑漏洞实战

关于超星脚本出现乱码问题

Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence

HackMyvm靶机系列(1)-webmaster
随机推荐
C language file operation
Interpretation of iterator related "itertools" module usage
Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class
网络基础之路由详解
7-11 mechanic mustadio (PTA program design)
7-14 error ticket (PTA program design)
XSS unexpected event
Tencent map circle
7-8 7104 Joseph problem (PTA program design)
《统计学》第八版贾俊平第八章假设检验知识点总结及课后习题答案
xray与burp联动 挖掘
Record an API interface SQL injection practice
Load balancing ribbon of microservices
Realize applet payment function with applet cloud development (including source code)
The difference between layer 3 switch and router
Detailed explanation of network foundation
HackMyvm靶機系列(3)-visions
HackMyvm靶机系列(4)-vulny
《统计学》第八版贾俊平第九章分类数据分析知识点总结及课后习题答案
Wu Enda's latest interview! Data centric reasons