当前位置:网站首页>[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
边栏推荐
- 【指针】查找最大的字符串
- 关于交换a和b的值的四种方法
- Markdown font color editing teaching
- Mathematical modeling idea of 2022 central China Cup
- Numpy Quick Start Guide
- Uibutton status exploration and customization
- 【指针】求二维数组中最大元素的值
- Attack and defense world misc practice area (GIF lift table ext3)
- 数字电路基础(三)编码器和译码器
- Lintcode logo queries the two nearest saplings
猜你喜欢

Record once, modify password logic vulnerability actual combat

5 minutes to master machine learning iris logical regression classification

Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?

Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator

Xray and burp linkage mining

Detailed explanation of network foundation

JDBC read this article is enough

. Net6: develop modern 3D industrial software based on WPF (2)

Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary

Data mining - a discussion on sample imbalance in classification problems
随机推荐
Pointers: maximum, minimum, and average
链队实现(C语言)
“人生若只如初见”——RISC-V
Build domain environment (win)
XSS unexpected event
Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
Chain team implementation (C language)
{1,2,3,2,5}查重问题
Function: find the maximum common divisor and the minimum common multiple of two positive numbers
Constants, variables, and operators of SystemVerilog usage
Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
MSF generate payload Encyclopedia
【指针】使用插入排序法将n个数从小到大进行排列
使用 flask_whooshalchemyplus jieba实现flask的全局搜索
内网渗透之内网信息收集(三)
Intranet information collection of Intranet penetration (5)
Statistics, 8th Edition, Jia Junping, Chapter 6 Summary of knowledge points of statistics and sampling distribution and answers to exercises after class
Hackmyvm target series (1) -webmaster
《统计学》第八版贾俊平第四章总结及课后习题答案
Proceedingjoinpoint API use