Advertisement
a53

datapal

a53
Feb 17th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3.  
  4. bool pal(char s[])
  5. {
  6. for(int i=0;i<=3;++i)
  7. if(s[i]!=s[8-i-1])
  8. return false;
  9. return true;
  10. }
  11.  
  12. int main()
  13. {
  14. int n;
  15. ifstream f("datapal.in");
  16. f>>n;
  17. char s[9];
  18. int F[100]={0},N=0;
  19. while(n--)
  20. {
  21. f>>s;
  22. if(pal(s))
  23. ++N,F[(s[4]-'0')*10+(s[5]-'0'+1)]=1;
  24. }
  25. f.close();
  26. ofstream g("datapal.out");
  27. g<<N<<'\n';
  28. if(N==0)
  29. g<<"NU EXISTA DATE PALINDROM";
  30. else
  31. {
  32. for(int i=0;i<100;++i)
  33. if(F[i])
  34. g<<i<<' ';
  35. }
  36. g.close();
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement