Advertisement
elena1234

ReplaceRepeatingChars

Nov 13th, 2020 (edited)
734
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. namespace ReplaceRepeatingChars
  5. {
  6.     class MainClass
  7.     {
  8.         public static void Main(string[] args)
  9.         {
  10.             string text = Console.ReadLine();
  11.             var sb = new StringBuilder();
  12.  
  13.             for (int i = 0; i < text.Length-1; i++)
  14.             {
  15.                 if (text[i] != text[i + 1])
  16.                 {
  17.                     sb.Append(text[i]);
  18.                 }
  19.             }
  20.  
  21.             sb.Append(text[text.Length-1]);
  22.             Console.WriteLine(sb);
  23.         }
  24.     }
  25. }    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement