Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Problem_04
- {
- class Program
- {
- static void Main()
- {
- string[] inputElements = Console.ReadLine().Split(' ').ToArray();
- string tempStr = "";
- tempStr = inputElements[0];
- for (int i = 0; i < inputElements.Length; i++)
- {
- if (i < inputElements.Length-1)
- {
- if (inputElements[i] == inputElements[i + 1])
- {
- if (tempStr == "")
- {
- tempStr = inputElements[i];
- }
- tempStr = tempStr + " " + inputElements[i + 1];
- if (i == inputElements.Length-2)
- {
- Console.WriteLine(tempStr);
- }
- }
- else
- {
- if (tempStr == "")
- {
- tempStr = inputElements[i];
- }
- Console.WriteLine(tempStr);
- tempStr = "";
- }
- }
- else
- {
- if (inputElements.Length > 1 && (inputElements[inputElements.Length-1] != inputElements[inputElements.Length-2]))
- {
- tempStr = inputElements[inputElements.Length-1];
- Console.WriteLine(tempStr);
- }
- else if (inputElements.Length == 1)
- {
- tempStr = inputElements[i];
- Console.WriteLine(tempStr);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement