当前位置:网站首页>Two dimensional array and function call cases of C language
Two dimensional array and function call cases of C language
2022-06-25 05:14:00 【Distant Aoki】
#include <stdio.h>
void initarray(int array[][5],int hang,int lie);// Semicolon is required for function definition
void printarray(int array[][5],int hang,int lie);
int getmax(int array[][5],int hang,int lie);
int main()
{ int max;
int array[4][5];
initarray(array,4,5);
printarray(array,4,5);
max=getmax(array,4,5);
printf(" The maximum value in a two-dimensional array is :%d\n",max);
}
// Initialize array
void initarray(int array[][5],int hang,int lie)// The second parameter of two-dimensional array [] It can't be empty
{ int i;
int j;
for(i=0;i<hang;i++)
{
for(j=0;j<lie;j++)
{
printf(" Please enter the first %d Xing di %d Column elements :\n",i+1,j+1);
scanf("%d",&array[i][j]);
}
}
}
// Print array
// The second dimension in the wrapper function has been fixed , therefore main The second dimension of the array in the function is also limited
void printarray(int array[][5],int hang,int lie)
{
int i;
int j;
for(i=0;i<hang;i++)
{
for(j=0;j<lie;j++)
{
printf("%d ",array[i][j]);
}
putchar('\n');
}
}
// Get the maximum value of two-dimensional array
int getmax(int array[][5],int hang,int lie)
{
int i;
int j;
int max;
max=array[0][0];
for(i=0;i<hang;i++)
{
for(j=0;j<lie;j++)
{ if(max<array[i][j])
{
max=array[i][j];
}
}
}
return max;
}
// The array is passed by address
边栏推荐
- Implementation of websocket long connection by workman under laravel
- Characteristics of ES6 arrow function
- Response (XI)
- [keil] GPIO output macro definition of aducm4050 official library
- A summary of the experiment of continue and break in C language
- Penetration test - right raising topic
- Drag modal box
- Ranorex Studio 10.1 Crack
- February 20ctf record
- CSRF (Cross Site Request Forgery) &ssrf (server request forgery) (IV)
猜你喜欢

Professional things use professional people

Qdebug June 2022

TX Text Control 30.0 ActiveX

Student achievement management system based on SSH

Penetration test - right raising topic

What is Ethernet and how to connect the computer

UVA816 Abbott’s Revenge

Wechat applet new version prompt update

How do the defi protocols perform under this round of stress test?

buuctf(re)
随机推荐
Precise delay based on Cortex-M3 and M4 (systick delay of system timer can be used for STM32, aducm4050, etc.)
How to use the Magic pig system reinstallation master
JS verification code input number auto skip
Database low-end SQL query statement fragment
hr竟主动给这位测试小姐姐涨工资,她是怎么做到的?
Install pytorch through pip to solve the problem that torch cannot be used in jupyter notebook (modulenotfoundererror:no module named 'Torch').
Svg code snippet of loading animation
Bind simulation, key points of interpreting bind handwritten code [details]
Route parameters to jump to the page and transfer parameters -- > hidden parameter list
[image fusion] image fusion based on MATLAB directional discrete cosine transform and principal component analysis [including Matlab source code 1907]
epplus复制模板后打印区域变小的问题
两小时带你进入软件测试行业风口(附全套软件测试学习路线)
Student achievement management system based on SSH
Penetration test - directory traversal vulnerability
Small sample learning data set
The SQL response is slow. What are your troubleshooting ideas?
Difference between asemi high power FET and triode
Matlab notes
February 19 CTF exercise
Critical dependency: require function is used in a way in which dependencies