Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <vector>
  4. using namespace std;
  5. void wyswietl(vector<int>pokaz)
  6. {
  7. for (int x = 0; x < pokaz.size(); x++)
  8. {
  9. cout << pokaz[x] << endl;
  10. }
  11. }
  12.  
  13. int suma(vector<int>sumowanie)
  14. {
  15. int y = 0;
  16. for (int x = 0; x < sumowanie.size(); x++)
  17. {
  18. y += sumowanie[x];
  19. }
  20. return y;
  21. }
  22.  
  23.  
  24. int main()
  25. {
  26.  
  27. vector<int>liczby;
  28. liczby.push_back(39);
  29. liczby.push_back(30);
  30. liczby.push_back(31);
  31. liczby.push_back(33);
  32. liczby.push_back(32);
  33.  
  34. cout << "Wyswietlanie liczb:" << endl;
  35. wyswietl(liczby);
  36.  
  37. int a = suma(liczby);
  38. cout << "Suma liczb: " << a << endl;
  39.  
  40. system("pause");
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement