public static void Main(string[] args) { Console.WriteLine("Please enter the numbers count (N):"); int numbersCount = FunctionsCollection.ReadIntInRange(1); Stack <int> numbersStack = ReadIntStack(numbersCount); Console.WriteLine("The reversed numbers collection is:"); PrintIntStack(numbersCount, numbersStack); }
public static void Main(string[] args) { Console.WriteLine("Please enter the first number in the sequence (N):"); int startNumber = FunctionsCollection.ReadIntInRange(); List <int> newSequence = GenerateSequence(startNumber, 50); Console.WriteLine("The result sequence with 50 members is:"); FunctionsCollection.PrintIntList(newSequence); }
private static Stack <int> ReadIntStack(int numbersCount) { Stack <int> numbersStack = new Stack <int>(); for (int i = 0; i < numbersCount; i++) { Console.WriteLine("Enter the next number:"); int currentNumber = FunctionsCollection.ReadIntInRange(); numbersStack.Push(currentNumber); } return(numbersStack); }
public static void Main(string[] args) { Console.WriteLine("Please enter the first number in the sequence (N):"); int startNumber = FunctionsCollection.ReadIntInRange(); Console.WriteLine("Please enter the searched number in the sequence (M > N):"); int searchedNumber = FunctionsCollection.ReadIntInRange(startNumber + 1); List <int> shortestSequence = GenerateShortestSequence(startNumber, searchedNumber); Console.WriteLine("The result shortest sequence from {0} to {1} is:", startNumber, searchedNumber); FunctionsCollection.PrintIntList(shortestSequence); }