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