Advertisement
palenda21

Untitled

Dec 10th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     char str[100];
  10.    
  11.     cout << "Vvedite stroku: ";
  12.     cin.getline(str, 100);
  13.     int n=strlen(str);
  14.     int count=0;
  15.     for(int i=n-1;i>0 ; i--)
  16.     {
  17.         if(str[i]==' '&& str[i-1]!=' ')
  18.         {
  19.             for(int j=i-1 ; str[j]!=' ';j--)
  20.             {
  21.                 count++;
  22.             }
  23.            
  24.             for(int k=0 ; k<count ; k++)
  25.             {
  26.                 for(int d =i-count-1 ; d<n-1 ; d++)
  27.                 {
  28.                     str[d]=str[d+1];
  29.                 }
  30.                 n--;
  31.             }
  32.        
  33.     }
  34.        
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement