当前位置:网站首页>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
边栏推荐
- Electronic Society C language level 1 28, character diamond
- What if win11 Bluetooth fails to connect? Solution of win11 Bluetooth unable to connect
- 2021-04-02
- Page electronic clock (use js to dynamically obtain time display)
- Ctfhub eggs
- In depth understanding of line height and vertical align
- 基于SSH实现的学生成绩管理系统
- [image fusion] image fusion based on MATLAB directional discrete cosine transform and principal component analysis [including Matlab source code 1907]
- ORA-00800: soft external error
- Penetration information collection steps (simplified version)
猜你喜欢

Svg code snippet of loading animation

Extend the toolbar of quill editor

Eyeshot Ultimate 2022 Crack By Xacker

TeeChart Pro ActiveX 2022.1

Array: force deduction dichotomy

Five simple data types of JS

《QDebug 2022年6月》

Detailed summary of flex layout

dotnet-exec 0.4.0 released

Compatible with Internet Explorer
随机推荐
The print area becomes smaller after epplus copies the template
Can bus extended frame
IronOCR 2022.1 Crack
JS function to realize simple calculator
How to make colleagues under the same LAN connect to their own MySQL database
Keyboard key code value
JS handwriting depth clone array and object
Wechat applet new version prompt update
A review of small sample learning
Electric store stores data
Cookie & session & JSP (XII)
TeeChart Pro ActiveX 2022.1
How to choose the years of investment in financial products?
Eyeshot Ultimate 2022 Crack By Xacker
Notes on non replacement elements in the line (padding, margin, and border)
CSRF (Cross Site Request Forgery) &ssrf (server request forgery) (IV)
Could not find “store“ in the context of “Connect(homePage)
OLAP analysis engine kylin4.0
For in JS Of and for in
Understand JS high-order function and write a high-order function