c語言 函數中數組的傳遞, 形參和實參。


 

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM