fbinnzhivko

02.00 Biggest Triple

Apr 17th, 2016
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. class BiggestTriple
  5. {
  6.     static void Main()
  7.     {
  8.         int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  9.        
  10.         int maxSum = Int32.MinValue;
  11.         int sum = 0;
  12.  
  13.         List<int> temp = new List<int>();
  14.         List<int> final = new List<int>();
  15.  
  16.         for (int i = 0; i < numbers.Length; i += 3)
  17.         {
  18.             temp = numbers.Skip(i).Take(3).ToList();
  19.             sum = temp.Sum();
  20.  
  21.             if (sum > maxSum)
  22.             {
  23.                 maxSum = sum;
  24.                 final = temp;
  25.             }
  26.         }
  27.         Console.WriteLine(string.Join(" ", final));
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment