Advertisement
MeehoweCK

Untitled

Dec 14th, 2020
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int liczba, suma = 0, licznik = -1;
  8.     do
  9.     {
  10.         cin >> liczba;
  11.         suma += liczba;
  12.         licznik++;
  13.     }
  14.     while(liczba != 0);
  15.  
  16.     cout << 1.0 * suma/licznik;     // aby program wypisywał faktyczną wartość (a nie całkowitą), to musimy najpierw kazać pomnożyć jedną z liczb przez 1.0
  17.  
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement