fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main() {
  7. vector <long double> v;
  8. long double a, average=0;
  9. while(cin>>a){
  10. average+=a;
  11. v.push_back(a);
  12. }
  13. average/=v.size();
  14. cout<<average<<'\n';
  15. for(int i=0; i<v.size(); i++)cout<<abs(v[i]-average)<<' ';
  16. return 0;
  17. }
Success #stdin #stdout 0s 16064KB
stdin
3
stdout
3
0