Advertisement
MeehoweCK

Untitled

Dec 6th, 2020
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n;
  7.     int suma=0;
  8.     int licznik=-1;
  9.  
  10.     do
  11.     {
  12.         ++licznik;
  13.         cin >> n;
  14.         suma += n;
  15.     } while(n != 0);
  16.  
  17.     if(licznik == 0)
  18.         cout << "Nie wpisales zadnej liczby. Nie da sie policzyc sredniej.\n";
  19.     else
  20.         cout<<1.0*suma/licznik;
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement