Guest User

Untitled

a guest
May 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Task01.SimulatesExecution
  7. {
  8.     class SimulatesExecution
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int n = int.Parse(Console.ReadLine());
  13.             string input = Console.ReadLine();
  14.             char separator = ' ';
  15.             string[] numbers = input.Split(separator);
  16.             decimal[] array = new decimal[n];
  17.             for (int i = 0; i < n; i++)
  18.             {
  19.                 array[i] = decimal.Parse(numbers[i]);
  20.             }
  21.  
  22.             Array.Sort(array);
  23.             decimal result = 0;
  24.             decimal bestResult = 0;
  25.             for (int i = 0; i < 1; i++)
  26.             {
  27.                 for (int j = 0; j < 1; j++)
  28.                 {
  29.                     for (int k = 0; k < array.Length; k++)
  30.                     {
  31.                         result = (array[n - 1] - array[k])*(array[k] - array[0]);
  32.                         if (result > bestResult)
  33.                         {
  34.                             bestResult = result;
  35.                         }
  36.                     }
  37.                 }
  38.             }
  39.             Console.WriteLine(bestResult);
  40.         }
  41.     }
  42. }
Add Comment
Please, Sign In to add comment