Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- template <typename Tip>
- Tip* Funk (std::vector<Tip> vek)
- {
- try
- {
- Tip* niz=new Tip [vek.size()];
- std::reverse_copy(vek.begin(), vek.end(), niz);
- return niz;
- }
- catch (std::bad_alloc)
- {
- throw "Alokacija nije uspjela.";
- }
- }
- int main () {
- std::vector <int> v;
- std::cout<<"Unesite elemente vektora (0 za kraj) : ";
- int n;
- while (std::cin>>n, n!=0) v.push_back(n);
- try {
- int* niz=Funk(v);
- for (int i=0; i<v.size(); i++) std::cout<<niz[i]<<" ";
- delete [] niz;
- }
- catch(const char e){
- std::cout<<"Greska: "<<e;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement