Advertisement
simonradev

Test

May 16th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. namespace ITVillage
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.     using System.Linq;
  6.     using System.Text;
  7.     using System.Threading.Tasks;
  8.    
  9.     public class Startup
  10.     {
  11.         public static void Main()
  12.         {
  13.             //1-vi variant
  14.             Methods.Output();
  15.             Console.WriteLine($"Max number is {Methods.GetMaxNumberFromConsoleInputs(int.Parse(Console.ReadLine()))}");
  16.  
  17.             //2-ri variant
  18.             Methods.Output();
  19.             Console.WriteLine($"Max number is {int.Parse(Console.ReadLine()).GetArrayFromConsoleInputs().Max()}");
  20.         }
  21.     }
  22.  
  23.     public static class Methods
  24.     {
  25.         public static readonly Action Output = () => Console.WriteLine("Vuvedi broq na chislata koito shte chetesh ot konzolata: ");
  26.  
  27.         public static readonly Func<int, int> GetMaxNumberFromConsoleInputs = input =>
  28.         {
  29.             int[] array = new int[input];
  30.             for (int currSymbol = 0; currSymbol < input; currSymbol++)
  31.             {
  32.                 array[currSymbol] = int.Parse(Console.ReadLine());
  33.             }
  34.  
  35.             return array.Max();
  36.         };
  37.  
  38.         public static int[] GetArrayFromConsoleInputs(this int number)
  39.         {
  40.             int[] array = new int[number];
  41.             for (int currInput = 0; currInput < number; currInput++)
  42.             {
  43.                 array[currInput] = int.Parse(Console.ReadLine());
  44.             }
  45.  
  46.             return array;
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement