欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

c語(yǔ)言輸入數(shù)組的函數(shù)

c語(yǔ)言輸入數(shù)組的函數(shù)?

代碼示例:

void print_array(int *arr, int len);

void sort_array(int *a, int n);

int main(void)

{

//建立一個(gè)無(wú)序的數(shù)組

int a[] = { 10,11,2,3,5,88,4,6,4,32,12 };

//獲取元素個(gè)數(shù)

int n = sizeof(a) / sizeof(a[0]);

printf("排序前\n");

//首先進(jìn)行一次輸出,數(shù)組、長(zhǎng)度作為輸入?yún)?shù)

print_array(a, n);

//給數(shù)組排序

sort_array(a, n);

printf("排序后\n");

//再次輸出數(shù)組的元素

print_array(a, n);

printf("\n");

system("pause");

return 0;

}

void print_array(int *arr, int len)

{

int n = sizeof(arr) / sizeof(arr[0]);//元素個(gè)數(shù)

printf("指針型數(shù)組長(zhǎng)度%d\n",n);

int i = 0;

for ( i = 0; i < len; i++)

{

printf("%d ",arr[i]);

}

printf("\n");

}

void sort_array(int *a, int n)

{

int i, j;

int temp;

//選擇法排序

for (i = 0; i < n - 1; i++)

{

for (j = i + 1; j < n; j++)

{

if (a[i] > a[j])

{

temp = a[i];

a[i] = a[j];

a[j] = temp;

}

}

}

}

java 數(shù)組做參數(shù),c語(yǔ)言輸入數(shù)組的函數(shù)