Advertisement
alch1337

Zadanie z informatyki dla bystrzaków

May 7th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdio>
  3.  
  4. using namespace std;
  5.  
  6. float LiczSrednia(float xSuma, float xIloscLiczb)
  7. {
  8.     return xSuma/xIloscLiczb;
  9. }
  10.  
  11. int main()
  12. {
  13.     int IloscLiczb;
  14.     float Liczba, Suma = 0;
  15.     cout<<"Podaj ilosc liczb, z ktorych chcesz wyliczyc srednia!"<<endl;
  16.     cin>>IloscLiczb;
  17.  
  18.     for (int i=1; i<=IloscLiczb; i++)
  19.     {
  20.         cout<<"Podaj liczbe nr "<<i<<"!"<<endl;
  21.         cin>>Liczba;
  22.         Suma = Suma + Liczba;
  23.     }
  24.    
  25.     cout<<"Srednia z tych liczb wynosi: "<<LiczSrednia(Suma, IloscLiczb);
  26.  
  27.     getchar();
  28.     cin.ignore();
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement