Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class BiggestTriple
- {
- static void Main()
- {
- // read, split and parse input line, store in a list of unrestricted count
- int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- // declaring variables
- int maxSum = Int32.MinValue;
- int sum = 0;
- List<int> temp = new List<int>();
- List<int> final = new List<int>();
- for (int i = 0; i < numbers.Length; i +=3)
- {
- temp = numbers.Skip(i).Take(3).ToList();
- sum = temp.Sum();
- if (sum > maxSum)
- {
- maxSum = sum;
- final = temp;
- }
- }
- // printing the result
- Console.WriteLine(string.Join(" ", final));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement