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];
- char t[N];
- cin.getline(s, N);
- int len = strlen(s);
- int lenth = 0;
- for (int j = len - 1; j > 0; j--)
- {
- while (s[j] == ' ' && j != 0)
- {
- j--;
- }
- int end = j;
- while (s[j] != ' ' && j != 0)
- {
- j--;
- }
- int beg;
- if (j != 0)
- {
- beg = j + 1;
- }
- else
- {
- beg = j;
- }
- for (int i = beg, x = 0 + lenth; i <= end; i++, x++)
- {
- t[x] = s[i];
- }
- lenth += end - beg + 2;
- t[lenth - 1] = ' ';
- //cout << beg << ' ' << end << ' ' << lenth << endl;
- }
- t[lenth - 1] = '\0';
- cout << t;
- }
Add Comment
Please, Sign In to add comment