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;
- namespace Task01.SimulatesExecution
- {
- class SimulatesExecution
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- string input = Console.ReadLine();
- char separator = ' ';
- string[] numbers = input.Split(separator);
- decimal[] array = new decimal[n];
- for (int i = 0; i < n; i++)
- {
- array[i] = decimal.Parse(numbers[i]);
- }
- Array.Sort(array);
- decimal result = 0;
- decimal bestResult = 0;
- for (int i = 0; i < 1; i++)
- {
- for (int j = 0; j < 1; j++)
- {
- for (int k = 0; k < array.Length; k++)
- {
- result = (array[n - 1] - array[k])*(array[k] - array[0]);
- if (result > bestResult)
- {
- bestResult = result;
- }
- }
- }
- }
- Console.WriteLine(bestResult);
- }
- }
- }
Add Comment
Please, Sign In to add comment