Advertisement
AvengersAssemble

HappyBirthday

Feb 13th, 2014
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1.         public static string Smarty(string st)
  2.         {
  3.             string word, lastWord = "";
  4.             int i, nextI;
  5.             i = 0;
  6.             while (i < st.Length)
  7.             {
  8.                 nextI = st.IndexOf(' ', i);
  9.                 if (nextI < 0)
  10.                     nextI = st.Length;
  11.                 word = st.Substring(i, nextI - i);
  12.                 if (word.Equals(lastWord))
  13.                     st = st.Remove(i - 1, nextI - i + 1);
  14.                 else
  15.                     i = nextI + 1;
  16.                 lastWord = word;
  17.             }
  18.             return st;
  19.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement