Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- #define tokens " "
- #define NMAX 1000
- char v[NMAX][NMAX], s[NMAX], revs[NMAX];
- int n;
- void rev(char s[])
- {
- int n = strlen(s);
- for (int i = 0; i < n / 2; i++)
- swap(s[i], s[n - i - 1]);
- }
- int main()
- {
- cin.getline(s, NMAX);
- char *p = strtok(s, tokens);
- while (p)
- {
- strcpy(v[n], p);
- n++;
- p = strtok(NULL, tokens);
- }
- for (int i = 0; i < n - 1; i++)
- for (int j = i + 1; j < n; j++)
- {
- strcpy(revs, v[j]);
- rev(revs);
- if (!strcmp(revs, v[i]))
- cout << v[i] << ' ' << v[j] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement