Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class MaximalElementInPortion
- {
- static void DescendingSort(int[] arr)
- {
- Console.WriteLine("Descending sort: ");
- Array.Reverse(arr);
- foreach (int num in arr)
- {
- Console.Write(num + " ");
- }
- Console.WriteLine();
- }
- static void AscendingSort(int[] arr)
- {
- Array.Sort(arr);
- Console.WriteLine("the biggest number in chosen portion is {0}", arr[arr.Length - 1]);
- Console.WriteLine("Ascending sort: ");
- foreach (int num in arr)
- {
- Console.Write(num + " ");
- }
- Console.WriteLine();
- DescendingSort(arr);
- }
- static void AddInNewArr(int[]array, int number)
- {
- int[] newArr = new int[array.Length-number];
- for (int i = 0; i < newArr.Length; i++)
- {
- newArr[i] = array[i + number];
- }
- AscendingSort(newArr);
- }
- static void Main()
- {
- int[] array = {6, 44, 90, -123, -69, 900, 55, 12, 700, 0, -130, -9, 32, 250 };
- int n = int.Parse(Console.ReadLine());
- AddInNewArr(array,n);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement