Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- std:: vector<int> f(std:: vector<int> v, int n)
- {
- std:: vector<int>w;
- int cifra, suma(0);
- for(int x:v)
- {
- int a(x);
- while(x!=0)
- {
- cifra=x%10;
- suma+=cifra;
- x=x/10;
- }
- if(suma>n) w.push_back(a);
- suma=0;
- }
- return w;
- }
- int main()
- {
- int n, a;
- std:: cout << "Unesite broj elemenata niza! ";
- std:: cin >> n;
- std:: vector<int> v(n);
- std:: cout << "Unesite elemente niza: ";
- for(int i=0; i<n; i++)
- std:: cin>> v[i];
- std:: cout << "Unesite broj: ";
- std:: cin >> a;
- std::vector<int> v1(f(v, a));
- std::cout << "Novi vektor glasi: ";
- for(int x : v1)
- std::cout << x << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement