C++程序代码解析:[27]数组参数

2026-04-01 13:44:28

1、#include "PRO.h"

//程序目录头文件

#include <iostream>

//输入输出头文件

C++程序代码解析:[27]数组参数

2、using namespace std;

//标识符空间

C++程序代码解析:[27]数组参数

3、int main()

//主函数

C++程序代码解析:[27]数组参数

4、int max(int x,int y);

//定义函数

int i,j,y,row=0,colum=0;

//定义变量

int a[2][3]={{2,4,5},{8,7,9}};

//给二维数组赋初始值

y=a[0][0];

C++程序代码解析:[27]数组参数

5、for(i=0;i<2;i++)

for(j=0;j<3;j++)

{

y=max(a[i][j],y);//调用函数

if(y==a[i][j])

{

row=i;

colum=j;

}

}

C++程序代码解析:[27]数组参数

6、int max(int x,int y)

//定义函数

{

if(x>y)

return x;

else

return y;

}

C++程序代码解析:[27]数组参数

7、程序完整源码如下:

C++程序代码解析:[27]数组参数

C++程序代码解析:[27]数组参数

8、程序运行结果如下:

C++程序代码解析:[27]数组参数

猜你喜欢