当前位置:网站首页>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
边栏推荐
- Mobile number regular expression input box loses focus verification
- Characteristics of ES6 arrow function
- Specific operations for uploading pictures in PHP
- TX Text Control 30.0 ActiveX
- Deeply understand the characteristics of standard flow and off standard elements
- epplus复制模板后打印区域变小的问题
- HR took the initiative to raise the salary of the test lady. How did she do it?
- Svg code snippet of loading animation
- Edge loss interpretation
- CSRF (Cross Site Request Forgery) &ssrf (server request forgery) (IV)
猜你喜欢

CSRF (Cross Site Request Forgery) &ssrf (server request forgery) (IV)

Array: force deduction dichotomy

How to use the Magic pig system reinstallation master

How to open the DWG file of the computer

Activereportsjs V3.0 comes on stage

Everything is an object

Extend the toolbar of quill editor

【FLink】access closed classloader classloader. check-leaked-classloader

TX Text Control 30.0 ActiveX

SQL lab range explanation
随机推荐
Jason learning
Use serialize in egg to read and write split tables
Native JS high risk reminder pop-up code snippet, "are you sure you want to do this?" and "it cannot be recovered after deletion. Do you want to continue“
What if win11 Bluetooth fails to connect? Solution of win11 Bluetooth unable to connect
Dynamic programming example 2 leetcode62 unique paths
Kotlin compose perfect todo project surface rendering background and shadow
H5 native player [learn video]
Essais de pénétration - sujets d'autorisation
WPF uses Maui's self drawing logic
Laravel's little knowledge
Basic knowledge of web pages (URL related)
DOM document object model (I)
Five simple data types of JS
Virtual honeypot Honeyd installation and deployment
[relax's law of life lying on the square] those poisonous chicken soup that seem to be too light and too heavy, but think carefully and fear
A review of small sample learning
Integrate CDN to create the ultimate service experience for customers!
XSS (cross site script attack) summary (II)
JS function to realize simple calculator
渗透测试-目录遍历漏洞