fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main() {
  7. double a=0,s=0,z;
  8. int y;
  9. vector<int> x;
  10. while(cin>>z){
  11. x.push_back(z);
  12. }
  13. for (int i=0;i<x.size();i++){
  14. a+=x[i];
  15. }
  16. a=a/x.size();
  17. for (int i=0;i<x.size();i++){
  18. s=s+(a-x[i])*(a-x[i]);
  19. }
  20. s=s/(x.size()-1);
  21. s=sqrt(s);
  22. cout<<a<<" ";
  23. cout<<s<<" ";
  24. return 0;
  25. }
Success #stdin #stdout 0s 3472KB
stdin
2 8 3 4 5 6 7 9 11 15 17 12 19 7 5 1 7 9 19 14
stdout
9 5.45797