StoimenK

C#_Lists_1.2.Gauss'_Trick

Feb 28th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 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. namespace _1._2.Gauss__Trick
  8. {
  9.     class Program
  10.     {
  11.         static void Main()
  12.         {
  13.             List<int> numbers = Console.ReadLine().Split().Select(int.Parse).ToList();
  14.  
  15.             int count = numbers.Count / 2;
  16.  
  17.             for (int i = 0; i < count; i++)
  18.             {
  19.                 numbers[i] += numbers[numbers.Count - 1];
  20.                 numbers.RemoveAt(numbers.Count - 1);
  21.                
  22.             }
  23.  
  24.             Console.WriteLine(string.Join(" ", numbers));
  25.         }
  26.     }
  27. }
Add Comment
Please, Sign In to add comment