Advertisement
gospod1978

List\Gauss' Trick

Oct 17th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace fundamental14
  6. {
  7.     class MainClass
  8.     {
  9.         public static void Main()
  10.         {
  11.  
  12.         List<double> number = Console.ReadLine().Split().Select(double.Parse).ToList();
  13.        
  14.        List<double> list = new List<double>();
  15.        
  16.        for (int i = 0; i < number.Count / 2; i++)
  17.          {
  18.          double sumNumber = number[i] + number[number.Count - 1 - i];
  19.             list.Add(sumNumber);
  20.          }
  21.          
  22.          if (number.Count % 2 == 1)
  23.          {
  24.             list.Add(number[number.Count / 2]);
  25.          }
  26.        
  27.          Console.WriteLine(string.Join(" ", list));
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement