Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- #include <string>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- setlocale(0,"rus");
- string s,b;
- int i,j, k,n;
- cout<<"Введите строку"<<endl;
- getline (cin,s);
- k=s.length()-1;
- for(i=s.length()-1; i>=0;i--)
- {
- if (s[i]==' ')
- {
- n=i+1;
- for (j=n;j<=k;j++)
- {
- b=b+s[j];
- }
- b=b+' ';
- k=i;
- }
- }
- if (s[0]!=' ')
- {
- i=0;
- do
- {
- b=b+s[i];
- i++;
- }while(s[i]!=' ');
- }
- cout<<b<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment