Venciity

[ Telerik C#] LOOPS - EX 3 by Alex

Feb 9th, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. //Write a program that reads from the console a sequence of N integer numbers and returns the minimal and maximal of them.
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace ex3
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             Console.Write("numbers = ");
  16.             int n = Int32.Parse(Console.ReadLine());
  17.             List<int> newList = new List<int> { };
  18.  
  19.             for (int i = 0; i < n; i++)
  20.             {
  21.                 Console.Write("number {0} = ",i+1);
  22.                 int g = int.Parse(Console.ReadLine());
  23.                 newList.Add(g);
  24.             }
  25.             Console.WriteLine("Max value : {0}",newList.Max());
  26.             Console.WriteLine("Min value : {0}", newList.Min());
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment