Advertisement
sellmmaahh

Sredine (arit. i harm.)

Jul 28th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. void Sredine (int n, double &AS, double &HS) {
  8.     int pom{n}, br_cifara{0};
  9.     double as{0}, hs{0};
  10. while (n!=0) {
  11.     br_cifara++;
  12.     as+=n%10;
  13.     hs+=1./(n%10);
  14.     n/=10;
  15. }
  16. AS=as/br_cifara;
  17. HS=br_cifara/hs;
  18. }
  19.  
  20. int main () {
  21. double h,a;
  22. Sredine(114,a,h);
  23. cout<<"Aritmeticka s. : "<<a<<endl;
  24. cout<<"Harmonijska s. : "<<h;
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement