c++中如何把数组作为参数

日期:2018-05-17 13:55:49 人气:1

c++中如何把数组作为参数

对于数组名作为参数传递,有两种方式: 1. 使用数组名本身,如以下程序求数组a的最大值 #include int max(int x[],int n) //作为数组定义形式 { int i,m=x[0]; for(i=1;i<n;i++) if(m<x[i]) m=x[i]; return m; } int main(void) { int a[5]={10,32,45,12,26}; int m; m=max(a,5); &#
    A+
热门评论