Advertisement
Guest User

Untitled

a guest
Oct 1st, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. void ispremjesaj(vector<int>& brojevi) {
  6. swap(brojevi[0], brojevi[brojevi.size() - 1]);
  7. }
  8.  
  9. void ispisi(vector<int>& brojevi) {
  10. for (auto it = brojevi.begin(); it != brojevi.end(); ++it) {
  11. cout << *it << endl;
  12. }
  13. }
  14.  
  15. int main() {
  16. vector<int> brojevi;
  17.  
  18. int n;
  19. cin >> n;
  20.  
  21. int broj;
  22. for (int i = 0; i < n; i++)
  23. {
  24. cout << "Unesi " << (i + 1) << ". broj: ";
  25.  
  26. cin >> broj;
  27. brojevi.push_back(broj);
  28. }
  29.  
  30. ispremjesaj(brojevi);
  31. ispisi(brojevi);
  32.  
  33. char a;
  34. cin >> a;
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement