Max Contiguous Subarray
Given a list of integers, write a program to identify the contiguous sub-list that has the largest sum and print the sum. Any non-empty slice of the list with step size 1 can be considered as a contiguous sub-list.Input
The input will contain space-separated integers, denoting the elements of the list.Output
The output should be an integer.Explanation
For example, if the given list is [2, -4, 5, -1, 2, -3], then all the possible contiguous sub-lists will be,
[2]
[2, -4]
[2, -4, 5]
[2, -4, 5, -1]
[2, -4, 5, -1, 2]
[2, -4, 5, -1, 2, -3]
[-4]
[-4, 5]
[-4, 5, -1]
[-4, 5, -1, 2]
[-4, 5, -1, 2, -3]
[5]
[5, -1]
[5, -1, 2]
[5, -1, 2, -3]
[-1]
[-1, 2]
[-1, 2, -3]
[2]
[2, -3]
[-3]Among the above contiguous sub-lists, the contiguous sub-list [5, -1, 2] has the largest sum which is 6.
Sample Input 1
2 -4 5 -1 2 -3
Sample Output 1
6
Sample Input 2
-2 -3 4 -1 -2 1 5 -3
Sample Output 2
7
write a complete C++ program that: a) initially asks the user to enter five sets of first name, last name and age; b) extracts the first name initial from the entered first name; c) uses arrays to store the entered information; and d) displays on the output monitor all the five sets of entered information in a table form as shown in sample output below.
Write a complete C++ program to write numbers 1 to 100 (vertically) in a data file NOTES.TXT
cin>> bilangan ;
for (int counter = 1; counter < bilangan ; counter ++)
cout<< counter + 2 <<” ”<<endl;
What is the output if bilangan is 4 ?
Given the following C++ program segment, determine the final value of variable current.
void calculate (int, int&);
int main() {
int current = 24, sum = 0; sum = current + 1;
calculate(sum, current);
cout << current; return 0;
}
void calculate (int number, int& current) {
current = current + number;
}
Create a class template for a class named Queue that holds
• A single data member as an array named list of size 10 to store certain elements
• A constructor to initialize queue with value 0 or 0.0 at all its indexes
• Three member functions i.e. sort() to sort the elements of the queue, max() that returns the maximum value present in the queue, min() that returns the smallest value present in the queue, and return_queue() that returns all the elements of the queue (in case of there being multiple maximum and minimum values present in the queue, the member functions should return notify the user of the number of times that value has been repeated in the queue and then return that value to the main function).
In the main() function, create three objects with different data types of class queue and test the functionality of member functions for various values of data members for these objects.
Write a main program to test the following functions:
void introduction() ; // to display a text to tell what is the program about
bool keepRunning(); // to ask the user for more times to run the program
void ruuProgram(); // to input an array, calculate series (k=0 to n) a^2*[k]
By making use of pseudocode, show the programming statements that will
accept two values from a user. These values should be added together and
the result displayed on the screen.
Explain a Java exception/error that you argue would be likely to occur in your example application.
come up with an example of a *class hierarchy* of at least 2 classes you argue would be needed for an application of your choice.