#include <stdio.h>
int average(int x[],int len){
int i,sum=0;
for(i=0;i<len;i++){
sum += x[i];
printf("%d\n",x[i]);
};
int a = sum / len;
printf("the average is %d \n",a);
};
int main(){
int score[10],i,len;
len = sizeof(score)/sizeof(score[0]);
for(i=0;i<len;i++){
printf("请输入第%d值:",i);
scanf("%d",&score[i]);
};
average(score,len);
printf("the score lengh is %d\n",len);
return 0;
};
结果:
请输入第0值:1
请输入第1值:2
请输入第2值:3
请输入第3值:4
请输入第4值:5
请输入第5值:6
请输入第6值:7
请输入第7值:8
请输入第8值:9
请输入第9值:10
1
2
3
4
5
6
7
8
9
10
the average is 5
the score lengh is 10
Process returned 0 (0x0) execution time : 5.015 s
Press any key to continue.
标签:10,int,小题目,score,成绩,输入
From: https://www.cnblogs.com/blueBear-19210723/p/18539256