Advertisement
alidzhikov

SequencesOfEqualStrings

May 7th, 2015
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4.  
  5. class SequencesOfEqualStrings
  6. {
  7.     static void Main()
  8.     {
  9.         string inputLine = Console.ReadLine();
  10.  
  11.         string[] tokens = inputLine.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
  12.  
  13.         for (int i = 0; i < tokens.Length - 1; i++)
  14.         {
  15.             if (String.Compare(tokens[i], tokens[i + 1], StringComparison.InvariantCulture) != 0)
  16.             {
  17.                 Console.WriteLine(tokens[i]);
  18.             }
  19.             else
  20.             {
  21.                 Console.Write("{0} ", tokens[i]);
  22.             }
  23.         }
  24.         Console.WriteLine(tokens[tokens.Length - 1]);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement