Question: Please Answer all questions in C++ 1 Write a program that takes in any integer x where 0

Please Answer all questions in C++

1

Write a program that takes in any integer x where 0 <= x <= 10 000. Your program should output the English phrase which is associated with that integer.

Input: 100

Output: One Hundred

Input: 102

Output: One Hundred and Two

Input: 42

Output: Forty Two

2

Write a program that takes in an array of numbers separated by commas. Suppose the numbers in the array are indexed starting from zero (as they are in C++).

Your program needs to identify the start and end indices of the smallest sub-array which when sorted will result in the whole input array to be sorted.For example, if we input the following array:1,2,3,6,5,4,7,8,9

Then the smallest sub-array which needs to be sorted would start at index 3 and end at index 5.Therefore the output is 3 5

Here are more examples of Input and output for this problem.

Input: 1,3,8,9,10,14,7,18,20

Output: 2 6

Input: 3,4,6,7,9,10,12,15,12,63,5,11,64

Output: 2 11

3.

Write a program that takes in a square matrix of integers and outputs the largest sub-square-matrix sum.

The first line of input is an integer which indicates the dimension of the square matrix, followed by the actual matrix row-by-row.

Input: 3

1 2 3

4 5 6

7 8 9

Output: 45

Input: 3

1 2 3

4 5 6

-7 -8 -9

Output: 16

NB: Since the largest square matrix is [2 3; 5 6] which sums to 16

Hint: Derive your algorithm from Kadanes Algorithm from Analysis of Algorithms Lab

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!