Advertisement
borko9696

Problem 4. Sequences of Equal Strings

Sep 15th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. class SequencesOfEqualStrings
  8. {
  9.     static void Main()
  10.     {
  11.         string[] arr = Console.ReadLine().Split(' ');
  12.         for (int i = 0; i < arr.Length; i++)
  13.         {
  14.             if (i==arr.Length-1)
  15.             {
  16.                 if (arr[i-1]==arr[i])
  17.                 {
  18.                     Console.Write("{0} ",arr[i]);
  19.                 }
  20.                 else
  21.                 {
  22.                     Console.WriteLine("{0}",arr[i]);
  23.                 }
  24.             }
  25.             else if (arr[i]!=arr[i+1])
  26.             {
  27.                 Console.WriteLine("{0}", arr[i]);
  28.             }
  29.             else if (arr[i]==arr[i+1])
  30.             {
  31.                 Console.Write("{0} ", arr[i]);
  32.             }
  33.            
  34.         }
  35.         Console.WriteLine();
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement