当前位置:网站首页>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
边栏推荐
- How to use the Magic pig system reinstallation master
- Handwritten promise all
- Specific operations for uploading pictures in PHP
- UVA816 Abbott’s Revenge
- parallel recovery slave next change & parallel recovery push change
- File upload vulnerability (III)
- Eyeshot 2022 Released
- Google Earth engine (GEE) - Global jrc/gsw1_ 1 / batch download of yearlyhistory dataset (China region)
- Filter & listener (XIV)
- ASEMI大功率场效应管和三极管的区别
猜你喜欢

Attack and defense world web baby Web

SQL lab range explanation

IronOCR 2022.1 Crack

基于SSH实现的学生成绩管理系统

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

Everything is an object

Create an environment for new projects

Svg code snippet of loading animation

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

MySQL prevents Chinese garbled code and solves the problem of Chinese garbled code
随机推荐
A summary of the experiment of continue and break in C language
Creation and use of MySQL index
Response (XI)
Laravel's little knowledge
Flex flexible layout for mobile terminal page production
Attack and defense world web baby Web
H5 canvas drawing circle drawing fillet [detailed explanation]
Two hours to take you into the software testing industry (with a full set of software testing learning routes)
Detailed summary of flex layout
Edge loss interpretation
buuctf(pwn)
Summary of SQL injection (I)
Startup mode of SoC verification environment
ThinkPHP 5 log management
The print area becomes smaller after epplus copies the template
Rce code execution & command execution (V)
Handwritten promise all
Personalized Federated Learning with Moreau Envelopes
Characteristics of ES6 arrow function
2021-03-23