albatroz56

Untitled

Jul 28th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. float srednia (float *wsk, int howmany)
  7. {
  8. float suma = 0;
  9.  
  10. for (int i=0; i<howmany; i++)
  11. {
  12. suma = suma+*wsk;
  13. wsk++;
  14. }
  15. return suma/howmany;
  16. }
  17.  
  18.  
  19. int main()
  20. {
  21.  
  22. float ile, liczba[300];
  23. float suma = 0;
  24.  
  25. cout << "Podaj ile liczb chcesz wpisac: " << endl;
  26. cin >> ile;
  27.  
  28.  
  29. cout << "Podaj " << ile <<" liczb: ";
  30.  
  31. for (int i=0; i<ile; i++)
  32. {
  33. cin >> liczba[ile];
  34. suma = suma+liczba[ile];
  35. }
  36. cout << "Suma to: " << suma << " a srednia to: " << srednia(liczba, ile);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment