Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Task_1
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class Program
- {
- public static void Main()
- {
- string numbersFromConsole = Console.ReadLine(); //1.read numbers from console
- var arrayOfNumbers = numbersFromConsole // 2.split the numbers by space and parse them to array
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- Array.Sort(arrayOfNumbers); //3. sorting the array
- //TODO:
- // last answer!
- for (int i = 0; i < arrayOfNumbers.Length - 1; i++)
- {
- if (arrayOfNumbers[i + 1] - arrayOfNumbers[i] == 1)
- {
- continue;
- }
- else
- {
- Console.WriteLine("Not consecutive numbers");
- return;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement