Advertisement
a53

asociat_par

a53
Dec 5th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool palindrom(int n)
  5. {
  6. int cn=n,ogl=0;
  7. while(n) ///construirea oglinditului
  8. ogl=ogl*10+n%10,n=n/10;
  9. if(cn==ogl)
  10. return true;
  11. return false;
  12. }
  13.  
  14. bool nrparasociat(int n,int &na)
  15. {
  16. int p=1,ncp=0;
  17. na=0;
  18. if(n==0)
  19. return true;
  20. while(n)
  21. {
  22. if(n%10%2==0)
  23. ++ncp,na+=p*(n%10),p*=10;
  24. n/=10;
  25. }
  26. if(ncp)
  27. return true;
  28. return false;
  29. }
  30.  
  31. int main()
  32. {
  33. int n;
  34. cin>>n;
  35. int x,xa=0;
  36. int c=0;
  37. for(int i=1;i<=n;++i)
  38. {
  39. cin>>x;
  40. if(nrparasociat(x,xa))
  41. if(palindrom(xa))
  42. ++c;
  43. }
  44. cout<<c;
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement