当前位置:网站首页>[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
边栏推荐
- JDBC事务、批处理以及连接池(超详细)
- Hcip -- MPLS experiment
- XSS (cross site scripting attack) for security interview
- Xray and Burp linked Mining
- servlet中 servlet context与 session与 request三个对象的常用方法和存放数据的作用域。
- Intel oneapi - opening a new era of heterogeneity
- 内网渗透之内网信息收集(四)
- Intranet information collection of Intranet penetration (3)
- JVM memory model concept
- 《统计学》第八版贾俊平第二章课后习题及答案总结
猜你喜欢
JDBC transactions, batch processing, and connection pooling (super detailed)
Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary
Data mining - a discussion on sample imbalance in classification problems
List and data frame of R language experiment III
Record an edu, SQL injection practice
关于交换a和b的值的四种方法
内网渗透之内网信息收集(四)
Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator
Ucos-iii learning records (11) - task management
Low income from doing we media? 90% of people make mistakes in these three points
随机推荐
函数:求1-1/2+1/3-1/4+1/5-1/6+1/7-…+1/n
Ucos-iii learning records (11) - task management
【指针】删除字符串s中的所有空格
[issue 18] share a Netease go experience
Solutions to common problems in database development such as MySQL
《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
内网渗透之内网信息收集(二)
Pointeurs: maximum, minimum et moyenne
Web vulnerability - File Inclusion Vulnerability of file operation
Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary
函数:计算字符串中大写字母的个数
【指针】数组逆序重新存放后并输出
Numpy Quick Start Guide
Function: calculates the number of uppercase letters in a string
Hackmyvm target series (2) -warrior
ES全文索引
Hcip -- MPLS experiment
Captcha killer verification code identification plug-in
数字电路基础(五)算术运算电路
内网渗透之内网信息收集(三)