Advertisement
naskedvi

S2 - zad.23

Mar 9th, 2014
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4.  
  5. std:: vector<int> f(std:: vector<int> v)
  6. {
  7. int cifra, brojac=0;
  8. std:: vector<int>w;
  9. for(int x:v)
  10. {
  11. while(x!=0)
  12. {
  13. cifra=x%10;
  14. brojac++;
  15. x=x/10;
  16. }
  17. w.push_back(brojac);
  18. brojac=0;
  19. }
  20. return w;
  21. }
  22.  
  23. int main()
  24. {
  25. int n;
  26.  
  27. std:: cout << "Unesite broj elemenata niza! ";
  28. std:: cin >> n;
  29. std:: vector<int> v(n);
  30. std:: cout << "Unesite elemente niza: ";
  31. for(int i=0; i<n; i++)
  32. std:: cin>> v[i];
  33.  
  34. std::vector<int> v1(f(v));
  35. std::cout << "Novi vektor glasi: ";
  36. for(int x : v1)
  37. std::cout << x << " ";
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement