Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

GetNumber and Getarray parts are working but I need help figuring out part 7_4 and 7_5 (I do not need Printarray). My professor provided the

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

GetNumber and Getarray parts are working but I need help figuring out part 7_4 and 7_5 (I do not need Printarray). My professor provided the sections in which we need to fill in with code to make them run and pass the test files provides by the professor in Visual Studio.

GetNumber Reuse the GetNumber0 method that you have been refining in the previous two labs Get Array Using your GetNumber0 method, create a method that will read in an array from the console. Begin by reading a number from the console which represents the size of the array to be read in. Then proceed to read in the specified number of elements Make sure to store the values obtained from the console in an array. PrintArray Develop a method that prints all the elements within the array passed to it. Exercise 7-4 Using the functions mentioned above, develop a routine that finds the longest consecutive sequence of integers. Should two integer values have consecutive sequences of the same length, the sequence composed of greater values would be the result (see example 2). Example 1: Consider the set (1, 2, 3, 3, 3,3,4,5, 5, 5), the result would be (3, 3, 3, 3) Example 2: Consider the set (1, 2, 5, 5, 5,4,4,4), even though there are consecutive sequences composed of 5's and 4's of length 3 the result should be the sequence composed of greater values, therefore the result is be (5, 5, 5) Exercise 7-5 Using the functions mentioned above, develop a routine that finds the longest consecutive sequence of consecutively increasing integers. In the event that there are two sequences that have the same length, the result should be the sequence that contains greater values (see example 2). Example 1: Consider the set (1, 2, 4,4, 5, 6, 7, the result would be (4, 5, 6, 7 Example 2: Consider the set 12, 4, 3,4, 5, 8, 1,2, 3) where there are two subsets (3, 4, 5) and (1, 2, 3) that satisfy the criteria. Your result should be (3, 4, 5) as it is the subset that satisfies the criteria with the greatest values. using System; 3 namespace ConsoleApp2 5 public class Program 7 public static void Main(string] args) int[] tmp,res; :res-Exercice7_4(tmp); 10 :;tmp GetArray() :PrintArray(res); :';// Exercice7_5 13 14 15 16 17 Epublic static int? GetNumber() :: if (int.TryParse(Console.ReadLine(), out int x)); 19 20 21 E : return x; 23 24: 25 26 27 28 Iese ::return null; :tw new NotImplementedException() 31 public static int[] GetArray() 32 33int[] array; int? length GetNumber(); 1 2 123456789 34 :; int? length -GetNumber); : while (lengthnull); 36 37 length-GetNumber); :if (length0) 39 40 41 42 return null; array-new int[length.Value]; for (int i- i 12, 2, 2) 79 80 :thow new NotImplementedException); 82 ublic static int[] Exercice7_5(int[] x) 83 84 85 86 87 :Write a program, which finds the maximal sequence of consecutively placed increasing integers Example: 13, 2, 3, 4, 2, 2, 4} -> 12, 3, 4) : throw new NotImplementedException(); 89 90 91 92 93 94

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions