当前位置:网站首页>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
边栏推荐
- IronOCR 2022.1 Crack
- How do the defi protocols perform under this round of stress test?
- The print area becomes smaller after epplus copies the template
- JS function to realize simple calculator
- Various pits encountered in the configuration of yolov3 on win10
- Page electronic clock (use js to dynamically obtain time display)
- Electric store stores data
- Mobile number regular expression input box loses focus verification
- Use js to simply implement the apply, call and bind methods
- Redis (17)
猜你喜欢
Eyeshot Ultimate 2022 Crack By Xacker
Go deep into the working principle of browser and JS engine (V8 engine as an example)
Essais de pénétration - sujets d'autorisation
Virtual honeypot Honeyd installation and deployment
Compatible with Internet Explorer
Wechat applet new version prompt update
Svg code snippet of loading animation
February 20ctf record
WPF uses Maui's self drawing logic
[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
随机推荐
Database overview
Understand JS high-order function and write a high-order function
Mysql interactive_ Timeout and wait_ Timeout differences
Penetration test - right raising topic
Database query optimization method
Object creation and invocation code example
Everything is an object
Opensea PHP development kit
How PHP gets the user's City
How to install the blue lake plug-in to support Photoshop CC 2017
Five simple data types of JS
Matlab notes
Vue uses keep alive to cache page optimization projects
Fun CMD command line~
Difference between asemi high power FET and triode
A brief talk on media inquiry
Kotlin compose listens to the soft keyboard and clicks enter to submit the event
Reading and writing of nodejs excel (.Xlsx) files
The article is on the list. Welcome to learn
2021-04-02