hdu2634

Doing Physics Experiment

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1035    Accepted Submission(s): 558


Problem Description
As far as Samuel is concerned,physics is very dull and doing the physics experiment is a waste of time. So Samuel only got a passing score in the experiment this semester. Dealing with the figures that get from the experiment requires a lot of energy and time,and it is not valuable to do it by press the calculator to get answer. So Samuel and his roommates often make up a program to work it out. Can you help Samuel make a program?
The problem is not hard. You only need to figure out the average M of n number(double type x1,x2,x3...xn) (the precision set as 10).
 

Input
test cases t,each of a test case contains a number n(an integer) and n figures(double type).
 

Output
Output the average M by “The average M = m.”here m is a number.
 

Sample Input
  
  
1 3 1.0 1.2 1.1
 

Sample Output

The average M = 1.1000000000.

AC代码:

#include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> using namespace std; int main() {         int t;         scanf("%d",&t);         while(t--)         {                 int n;                 scanf("%d",&n);                 double sum=0;                 for(int i=0;i<n;i++)                 {                         double a;                         scanf("%lf",&a);                         sum+=a;                 }                 printf("The average M = %.10lf.\n",sum/n);         }         return 0; }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值