Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1.  
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. setlocale (LC_ALL, "Russian");
  10.  
  11.     int chiselko = 0;
  12.     int sum= 0;
  13.     int count = 0;
  14.  
  15.     do
  16.  
  17.     {
  18.   cin>> chiselko;
  19. if (!cin)
  20. {
  21. cout<<("Не число");
  22. return 1;
  23. }
  24.  
  25. if (chiselko>0)
  26. {
  27.  
  28. count ++;
  29. sum= sum+chiselko;
  30. }
  31.     }
  32.  while (chiselko!=0 );
  33.  cout<< "Среднее арифмитическое чисел = "<< static_cast<double>(sum)/(count);
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement