LabiinfaCibGyti

zahita8

Dec 11th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4. #include <string>
  5. using namespace std;
  6. int _tmain(int argc, _TCHAR* argv[])
  7. {
  8.     setlocale(0,"rus");
  9.     string s,b;
  10.     int i,j, k,n;
  11.     cout<<"Введите строку"<<endl;
  12.     getline (cin,s);
  13.     k=s.length()-1;
  14.     for(i=s.length()-1; i>=0;i--)
  15.     {
  16.         if (s[i]==' ')
  17.         {
  18.             n=i+1;
  19.             for (j=n;j<=k;j++)
  20.             {
  21.                 b=b+s[j];
  22.             }
  23.             b=b+' ';
  24.             k=i;
  25.         }
  26.     }
  27.     if (s[0]!=' ')
  28.     {
  29.         i=0;
  30.         do
  31.         {
  32.         b=b+s[i];
  33.         i++;
  34.         }while(s[i]!=' ');
  35.     }
  36.     cout<<b<<endl;
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment