Advertisement
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;
- using System.Threading.Tasks;
- class EnterNumbers
- {
- static void Main()
- {
- int start = 1;
- int end = 100;
- int[] numbers = new int[10];
- Console.WriteLine("Enter 10 numbers in range [{0}...{1}]", start, end);
- for (int i = 0; i < 10; i++)
- {
- while (numbers[i] <= start || numbers[i] >= end || (i > 0 && numbers[i] <= numbers[i - 1]))
- {
- bool exeption = false;
- try
- {
- numbers[i] = Int32.Parse(Console.ReadLine());
- }
- catch (Exception e)
- {
- Console.WriteLine("Invalid number format!");
- exeption = true;
- }
- if ((numbers[i] <= start || numbers[i] >= end) && !exeption)
- {
- Console.WriteLine("Number not in range!");
- }
- else if (i > 0 && numbers[i] <= numbers[i - 1] && !exeption)
- {
- Console.WriteLine("Number must be bigger than {0}!", numbers[i - 1]);
- }
- }
- if (numbers[i] == 99)
- {
- break;
- }
- }
- Console.WriteLine(String.Join(", ", numbers));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement