infected_3d

pervayahreni

May 28th, 2013
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2.  
  3. class MyProg
  4. {
  5.     static void Main()
  6.         {
  7.             int maxnum = 0;
  8.             Console.WriteLine("Input the size of the array");
  9.             int ArSize = Convert.ToInt16(Console.ReadLine());
  10.             int[] numbers = new int[ArSize];
  11.             for (int i = 1; i < ArSize; i++)
  12.             {
  13.                 Console.WriteLine("Write {0} element of array", i);
  14.                 try
  15.                 {
  16.                     numbers[i] = Convert.ToInt16(Console.ReadLine());
  17.                 }
  18.                 catch
  19.                 {
  20.                     Console.WriteLine("Please type only real numbers.");
  21.                     i -= 1;
  22.                 }
  23.             }
  24.             foreach (int ArEl in numbers)
  25.             {
  26.                 if (maxnum < ArEl) {maxnum = ArEl;}
  27.             }
  28.             Console.WriteLine("maximum number in array is : {0}", maxnum);
  29.             Console.ReadLine();
  30.         }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment