Advertisement
momchipetkov

23.exercise

Feb 3rd, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4.  
  5. class Program
  6. {
  7.     static void Main()
  8.     {
  9.         string str = Console.ReadLine();
  10.         int count = 0;
  11.         int counts=0;
  12.         StringBuilder sb = new StringBuilder();
  13.         for (int i = 0; i < str.Length-1; i++)
  14.         {
  15.             counts++;
  16.             if (str[i] == str[i + 1])
  17.             {
  18.                 do
  19.                 {
  20.                     count++;
  21.                 } while (str[i] != str[i+1]);
  22.             }
  23.             if (count < counts)
  24.             {
  25.                 sb.Append(str[i]);
  26.                 count = 0;
  27.                 counts = 0;
  28.             }
  29.  
  30.         }
  31.         Console.Write(sb);
  32.         Console.WriteLine(str[str.Length - 1]);
  33.          
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement