Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class MoreExercises
- {
- static void Main()
- {
- var seqInt = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
- var listToSum = new List<int>();
- var removedInt = 0;
- while (true)
- {
- int index = int.Parse(Console.ReadLine());
- if (index < 0)
- {
- removedInt = seqInt[0];
- listToSum.Add(removedInt);
- seqInt[0] = seqInt[seqInt.Length - 1];
- for (int i = 0; i < seqInt.Length; i++)
- {
- if (seqInt[i] <= removedInt)
- {
- seqInt[i] = seqInt[i] + removedInt;
- }
- else if (seqInt[i] > removedInt)
- {
- seqInt[i] = seqInt[i] - removedInt;
- }
- }
- }
- else if (index > seqInt.Length - 1)
- {
- removedInt = seqInt[seqInt.Length - 1];
- listToSum.Add(removedInt);
- seqInt[seqInt.Length - 1]= seqInt[0];
- for (int i = 0; i < seqInt.Length; i++)
- {
- if (seqInt[i] <= removedInt)
- {
- seqInt[i] = seqInt[i] + removedInt;
- }
- else if (seqInt[i] > removedInt)
- {
- seqInt[i] = seqInt[i] - removedInt;
- }
- }
- }
- else
- {
- removedInt = seqInt[index];
- listToSum.Add(removedInt);
- seqInt = seqInt.Where(x => x != seqInt[index]).ToArray();
- for (int i = 0; i < seqInt.Length; i++)
- {
- if (seqInt[i] <= removedInt)
- {
- seqInt[i] = seqInt[i] + removedInt;
- }
- else if (seqInt[i]>removedInt)
- {
- seqInt[i] = seqInt[i] - removedInt;
- }
- }
- }
- if (seqInt.Length==0)
- {
- break;
- }
- }
- Console.WriteLine(listToSum.Sum());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement