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; }