Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int verifica_numarul(int numar);
  6. int main()
  7. {
  8. int n, nr, i, suma = 0;
  9.  
  10. cout << "Introdu cate numere sa verific: ";
  11. cin >> n;
  12.  
  13. for (i = 0; i < n; i++) {
  14. cout << "Introdu numarul pe care vrei sa-l verific: ";
  15. cin >> nr;
  16. if(verifica_numarul(nr)) {
  17. suma += nr;
  18. }
  19. }
  20.  
  21. cout << "Suma: " << suma;
  22. }
  23.  
  24. int verifica_numarul(int numar)
  25. {
  26. int cifra;
  27. while(numar) {
  28. cifra = numar % 10;
  29. numar /= 10;
  30. if(cifra % 2 != 0) {
  31. return 0;
  32. }
  33. }
  34. return 1;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement