Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int size = 0;
- cin >> size;
- char data[size];
- for(int i = 0; i < size; i++)
- {
- cin >> data[i];
- }
- bool cond = false;
- if((size % 2) == 0)
- {
- for(int j = 0; j < (size/2); j++)
- {
- if(data[j] == data[((size - j) - 1)])
- {
- cout << j << " " << data[j] << " " << ((size - j) - 1) << " " << data[((size - j) - 1)] << " ";
- cond = true;
- }
- else
- {
- cond = false;
- j = (size/2);
- }
- }
- }
- else
- {
- for(int j = 0; j < (size/2); j++)
- {
- if(data[j] == data[((size - j) - 1)])
- {
- cout << j << " " << data[j] << " " << ((size - j) - 1) << " " << data[((size - j) - 1)] << " ";
- cond = true;
- }
- else
- {
- cond = false;
- j = (size/2);
- }
- }
- }
- cout << endl;
- if(cond)
- {
- cout << "sim" << endl;
- }
- else
- {
- cout << "nao" << endl;
- }
- cout << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment