Advertisement
Guest User

vicotr

a guest
Feb 26th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int Oglindit(int N)
  6. {
  7. int ogl = 0;
  8. while(N > 0)
  9. {
  10. ogl = ogl * 10 + N % 10;
  11. N /= 10;
  12. }
  13. return ogl;
  14. }
  15.  
  16. int F(int X)
  17. {
  18. int numar = X, nr = 0, P = 1, y;
  19. int nrz = 0, nrt = 0, nri = 0;
  20. if(X == 0) return 0;
  21. while(numar > 0)
  22. {
  23. if(numar % 10 == 0) nrz++;
  24. if(numar % 2 == 1) nri++;
  25. if(numar % 2 == 0)
  26. {
  27. nr = nr + P * (numar % 10);
  28. P *= 10;
  29. }
  30. nrt++;
  31. numar /= 10;
  32. }
  33. if(nrt - nri == nrz) return 1;
  34. if(nrt == nri) return 0;
  35. y = Oglindit(nr);
  36. if(y == nr) return 1;
  37. return 0;
  38.  
  39. }
  40.  
  41. int main()
  42. {
  43. int K = 0, N, X;
  44. cin >> N;
  45. for(int i = 1 ; i <= N ; ++i)
  46. {
  47. cin >> X;
  48. if(F(X)) K++;
  49. }
  50. cout << K;
  51.  
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement