wojiaocbj

uncertain

Mar 30th, 2022
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. /*
  2.  Author: Cao Beijian
  3.  Result: AC Submission_id: 4265184
  4.  Created at: Thu Mar 31 2022 11:12:28 GMT+0800 (China Standard Time)
  5.  Problem_id: 5441   Time: 3 Memory: 2220
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <math.h>
  10. int main(){
  11.     double a[1024] = { 0 }, avg = 0.0, unc = 0.0;
  12.     int n = 0, i;
  13.     while(~scanf("%lf", a + n)){
  14.         avg += a[n];
  15.         n++;
  16.     }
  17.     avg /= n;
  18.     for(i = 0;i < n;i++){
  19.         unc += (a[i] - avg) * (a[i] - avg);
  20.     }
  21.     unc = sqrt(unc / (n * (n - 1)));
  22.     printf("%.4f %.4f\n", avg, unc);
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment