Advertisement
IanosStefanCristian

sub 3 problema 3

May 30th, 2021
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1.  
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int n;
  9. cin>>n;
  10. int v[n];
  11. for(int i = 0; i < n; i ++)
  12. {
  13. cin>>v[i];
  14. }
  15. for(int i = 0; i < n; i++)
  16. {
  17. int ok = 0;
  18. int cp = v[i];
  19. int c = -1;
  20. while(cp)
  21. {
  22. if(c == -1)
  23. {
  24. if((cp % 10) % 2 == 0)
  25. {
  26. c = cp % 10;
  27. cp = cp / 10;
  28. }
  29. else
  30. {
  31. cp = cp / 10;
  32. continue;
  33. }
  34. }
  35.  
  36. if(c != -1 && (cp % 10) % 2 == 0 &&cp % 10 != c)
  37. {
  38. ok = 1;
  39. break;
  40. }
  41. cp = cp / 10;
  42. }
  43. if(ok == 0 && c != -1)
  44. {
  45. cout<<v[i]<<endl;
  46. }
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement