啊哈磊_编程从这里起步
标题:
给你道题
[打印本页]
作者:
推荐人
时间:
2015-10-4 13:15
标题:
给你道题
TL:1000MS
ML:10000K
Description
计算平均值
Input
输入有n+1行,1-n行每行有m+1个数字。第一个数是m是这一行后面数字的个数。第2-m个数字的大小范围在0-32767之间。第n+1行包含1个0以结束输出
Output
输出有n行,每行包含1个整数,为输入第1-n行的第2-(m+1)个数字的平均数(向下取整)。
Sample Input
5 1 2 3 4 5
7 1 2 3 4 5 6 7
0
Sample Output
3
4
作者:
maxwell106
时间:
2016-12-17 13:20
本帖最后由 maxwell106 于 2016-12-17 13:24 编辑
[mw_shl_code=c,true]#include<stdio.h>
int main(){
int a,b,s,i;
while((scanf("%d",&a))!=EOF){
if(!a)break;
for(i=0,s=0;i<a;i++){
scanf("%d",&b);
s+=b;
}
printf("%d\n",s/a);
}
return 0;
}[/mw_shl_code]
欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/)
Powered by Discuz! X3.2