Pretorianbg

Untitled

Mar 24th, 2019
662
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Replace_Repeating_Chars
  4. {
  5. class Program
  6. {
  7. public static void Main(string[] args)
  8. {
  9. var text = Console.ReadLine();
  10.  
  11. for (int i = 0; i < text.Length - 1; i++)
  12. {
  13. while (text[i] == text[i + 1])
  14. {
  15. text = text.Remove(i + 1, 1);
  16.  
  17. if (i==text.Length-1)
  18. {
  19. break;
  20. }
  21. }
  22. }
  23.  
  24. Console.WriteLine(text);
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment