当前位置:网站首页>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
边栏推荐
- Laravel Aurora push
- Conflict between v-mode and v-decorator in Ant Design
- dotnet-exec 0.4.0 released
- A brief talk on media inquiry
- In depth understanding of line height and vertical align
- Use js to simply implement the apply, call and bind methods
- How to use the Magic pig system reinstallation master
- UVA816 Abbott’s Revenge
- The print area becomes smaller after epplus copies the template
- 电子协会 C语言 1级 28 、字符菱形
猜你喜欢

What if win11 Bluetooth fails to connect? Solution of win11 Bluetooth unable to connect

Reading and writing of nodejs excel (.Xlsx) files

CTFHUB SSRF

Summary of SQL injection (I)

File upload vulnerability (III)

Student achievement management system based on SSH

Deeply understand the characteristics of standard flow and off standard elements

Personalized Federated Learning with Moreau Envelopes
![[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](/img/12/d41f8d5abcb61d2632a8b117bf1604.jpg)
[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

HR took the initiative to raise the salary of the test lady. How did she do it?
随机推荐
Five simple data types of JS
Dynamic programming example 2 leetcode62 unique paths
API interface management setup -eolinker4.0
[keil] GPIO output macro definition of aducm4050 official library
Mobile number regular expression input box loses focus verification
Baidu ueeditor set toolbar initial value
Extend the toolbar of quill editor
Student achievement management system based on SSH
Penetration test - directory traversal vulnerability
Rce code execution & command execution (V)
H5 canvas drawing circle drawing fillet [detailed explanation]
XSS (cross site script attack) summary (II)
【FLink】access closed classloader classloader. check-leaked-classloader
Visual studio 2022 interface beautification tutorial
buuctf(pwn)
Small sample learning data set
Summary of SQL injection (I)
Using JS to realize the sidebar of life information network
Apache+php uploading large files
IronOCR 2022.1 Crack