Advertisement
sellmmaahh

popravni-sept-2014-zad7-count_if

Jul 30th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdexcept>
  3. #include <algorithm>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. int SumaCifara (const int &n) {
  9.     int pom(n), suma{0};
  10.     while (pom!=0) {
  11.         suma+=pom%10;
  12.         pom/=10;
  13.     }
  14.     return suma;
  15. }
  16.  
  17. int main () {
  18. cout<<"Unesite n: ";
  19. int n;
  20. cin>>n;
  21. int niz[10]={5,3,11,8,91,5,3,82,21,4};
  22. cout<<count_if(niz,niz+10, [n] (int x) {return SumaCifara(x)>n; });
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement