Guest User

Untitled

a guest
May 23rd, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int size = 0;
  7. cin >> size;
  8. char data[size];
  9. for(int i = 0; i < size; i++)
  10. {
  11. cin >> data[i];
  12. }
  13.  
  14. bool cond = false;
  15.  
  16. if((size % 2) == 0)
  17. {
  18. for(int j = 0; j < (size/2); j++)
  19. {
  20. if(data[j] == data[((size - j) - 1)])
  21. {
  22. cout << j << " " << data[j] << " " << ((size - j) - 1) << " " << data[((size - j) - 1)] << " ";
  23. cond = true;
  24. }
  25. else
  26. {
  27. cond = false;
  28. j = (size/2);
  29. }
  30. }
  31. }
  32. else
  33. {
  34. for(int j = 0; j < (size/2); j++)
  35. {
  36. if(data[j] == data[((size - j) - 1)])
  37. {
  38. cout << j << " " << data[j] << " " << ((size - j) - 1) << " " << data[((size - j) - 1)] << " ";
  39. cond = true;
  40. }
  41. else
  42. {
  43. cond = false;
  44. j = (size/2);
  45. }
  46. }
  47. }
  48. cout << endl;
  49. if(cond)
  50. {
  51. cout << "sim" << endl;
  52. }
  53. else
  54. {
  55. cout << "nao" << endl;
  56. }
  57.  
  58. cout << endl;
  59. return 0;
  60. }
Add Comment
Please, Sign In to add comment