Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. string foo(string str)
  2. {
  3.     char space = " ";
  4.     string res;
  5.    
  6.     //str.replace_all("  ", " ");
  7.     for(int i = 0; i < str.size(); i++)
  8.     {
  9.         if((str.at(i) == " ")  && (i < str.size()-1)
  10.         {
  11.         try{
  12.             if((str.at(i+1) == " "))
  13.             {
  14.                 continue;
  15.             }
  16.             else{
  17.                 res += srt.at(i);
  18.            
  19.             }
  20.            }
  21.         catch(out_of_range)
  22.         {
  23.            
  24.         }
  25.         }
  26.        
  27.         else
  28.         {
  29.             //end;
  30.              res += srt.at(i);
  31.         }
  32.     }
  33.    
  34.     return res;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement