写一个函数修改数组中的数据,在主函数中调用它。(C语言)?

Python010

写一个函数修改数组中的数据,在主函数中调用它。(C语言)?,第1张

#include<stdio.h>

// 用于修改数组的函数

int change_array(int *num, int count)

{

int i,t

for(i = 0i <counti++)

{

t = num[i]

num[i] = t + 1

}

}

int main()

{

int i, b[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }

// 调用函数

change_array(b, 10)

// 输出结果

for(i = 0i <10++i)

{

printf("%d ", b[i])

}

}

#include "stdio.h"

float aver(int a[],int n)

{

float aver=0

int i

for(i=0i<ni++)

aver+=a[i]

return aver/n

}

void main()

{ int a[10],i

int t //增加一个变量,用来标记计算n门课的平均成绩

printf("请输入成绩:")

for(i=0i<10i++)

scanf("%d",&a[i])

scanf("%d",&t)

printf("平均成绩为:%f\n",aver(a,t))

}