c语言, 函数中数组的传递,形参和实参。
1、
#include <stdio.h>
#define NUMBER 5
int func1(int x[], int y) ##函数中传递数组的形参 { int i, max = x[0]; for (i = 0; i < y; i++) { if (x[i] > max) max = x[i]; } return max; } int main(void) { int i, a[NUMBER], b[NUMBER], maxa, maxb; puts("please input the integers."); for (i = 0; i < NUMBER; i++) { printf("a[%d] = ", i); scanf("%d", &a[i]); printf("b[%d] = ", i); scanf("%d", &b[i]); } maxa = func1(a, NUMBER); ## 函数中数组的传递, 实参 maxb = func1(b, NUMBER); printf("the max a: %d\n.", maxa); printf("the max b: %d\n.", maxb); return 0; }