Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main()
- {
- const int N = 10000;
- char s[N];
- cin.getline(s, N);
- for (int i = 0; s[i]; )
- {
- while (s[i] == ' ')
- {
- i++;
- }
- if (s[i] == 0)
- {
- break;
- }
- int beg = i;
- while (s[i] && s[i] != ' ')
- {
- i++;
- }
- int end = i - 1;
- //cout << beg << ' ' << end << endl;
- for (int i = beg, j = end; i < j; i++, j--)
- {
- swap(s[i], s[j]);
- }
- for (int i = beg; i <= end; i++)
- {
- cout << s[i];
- }
- cout << ' ';
- }
- }
Add Comment
Please, Sign In to add comment