当前位置:网站首页>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
边栏推荐
- Electric store stores data
- TX Text Control 30.0 ActiveX
- Edge loss interpretation
- The article is on the list. Welcome to learn
- Deeply understand the characteristics of standard flow and off standard elements
- Page electronic clock (use js to dynamically obtain time display)
- Redis (17)
- epplus复制模板后打印区域变小的问题
- Install pytorch through pip to solve the problem that torch cannot be used in jupyter notebook (modulenotfoundererror:no module named 'Torch').
- On Transform
猜你喜欢

Go deep into the working principle of browser and JS engine (V8 engine as an example)

2021-03-23

XSS (cross site script attack) summary (II)

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

A review of small sample learning

渗透测试-提权专题
![H5 canvas drawing circle drawing fillet [detailed explanation]](/img/6f/a33a323b6cd0918066e8b71a22d841.jpg)
H5 canvas drawing circle drawing fillet [detailed explanation]

In depth understanding of line height and vertical align

Eyeshot Ultimate 2022 Crack By Xacker

In Net 6 using dotnet format formatting code
随机推荐
Laravel Aurora push
Create an environment for new projects
How micro engine uploads remote attachments
February 20ctf record
IronOCR 2022.1 Crack
Kotlin compose perfect todo project surface rendering background and shadow
Implementation of websocket long connection by workman under laravel
Various pits encountered in the configuration of yolov3 on win10
Penetration test - right raising topic
Mysql interactive_ Timeout and wait_ Timeout differences
buuctf web
Professional things use professional people
ORA-00800: soft external error
Database low-end SQL query statement fragment
2021-10-24
Deeply understand the characteristics of standard flow and off standard elements
The construction and usage of wampserver framework
Enhanced paste quill editor
Use serialize in egg to read and write split tables
parallel recovery slave next change & parallel recovery push change