日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

c语言数组数据的输入,在C语言中,数组中的值如何输入到函数中?

發布時間:2025/4/16 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言数组数据的输入,在C语言中,数组中的值如何输入到函数中? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我希望這有幫助:

#include

/* don't need to specify size of array1 here */

/* rather pass the no. of elements of array1 through n*/

int FillArray(int array1[], int n) {

/* observe, you've 10 elements in array1 */

/* that's why array2[10] */

/* size of array2 should be >= n */

int array2[10], i;

/* I replaced 9 with 10 as array1 */

/* has n elements...ranges 0 to n-1 */

for(i = 0; i < n; ++i) {

if (array1[i] > 0)

array2[i] = array1[i] * 2;

else

array2[i] = array1[i] * 10;

/* I didn't get this below line. */

/* Should it be outside the loop? or what you've tried to do here. */

/* If you want to print the content of array2,*/

/* then see your book how to print an array */

/* for an array of size n,*/

/*it's index range is 0 to n-1.....so 10 is not valid */

// printf("

%d", array2[10]); // this line

}

/* To print array2, in case if you want to know about it */

for(i=0; i

printf("%d

", array2[i]);

}

return 0;

}

int main() {

/* you don't have to specify size here */

/* but again, if you would like to specify */

/* it would be >= 10 as you've at least 10 elements in array1 */

int array1[] = { 40, 13, -5, 22, 10, 80, -2, 50, 9, -7 };

/* it's good habit to pass the no. of elements of an array */

FillArray(array1, 10);

return 0;

}

總結

以上是生活随笔為你收集整理的c语言数组数据的输入,在C语言中,数组中的值如何输入到函数中?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。