Question: Programming language - C=++ Number Pyramid is a great game for young children to practice their addition and subtraction skills and is much liked by

 Programming language - C=++ Number Pyramid is a great game for Programming language - C=++

Number Pyramid is a great game for young children to practice their addition and subtraction skills and is much liked by teachers as a pastime in class. In this game the player is supposed to find their way out of the pyramid by finding the missing value at the top of the pyramid. Every brick (except for the bottom row) is the sum of the two bricks on which it rests. For example, take the following pyramid (Figure a) of height 4: To find the way out the player must compute all needed missing cells to find the top value, as shown in Figure (b). Since you love a challenge, you decide to write a program that solves this game. Your program will be tested one or more test cases. Each test case will be specified using d-1 lines. The first line specifies an integer d (1 d 32) denoting the height of the pyramid. The following d lines describe the contents of every level of the pyramid. Values are separated by one or more spaces. For every value v at the base of the pyramid (last row) -10000 v 10000. Missing values are denoted using a dash '-'. The last line of the file contains a single -1. which is not part of the data set. For each test case print one line of output in the form: k: result; where k is the test case number (starting at 1), and result is the sum at the top of the pyramid. If the pyramid wasn't solvable you print "Nor solvable". Separate your result from the colon (:) by a single space. Number Pyramid is a great game for young children to practice their addition and subtraction skills and is much liked by teachers as a pastime in class. In this game the player is supposed to find their way out of the pyramid by finding the missing value at the top of the pyramid. Every brick (except for the bottom row) is the sum of the two bricks on which it rests. For example, take the following pyramid (Figure a) of height 4: To find the way out the player must compute all needed missing cells to find the top value, as shown in Figure (b). Since you love a challenge, you decide to write a program that solves this game. Your program will be tested one or more test cases. Each test case will be specified using d-1 lines. The first line specifies an integer d (1 d 32) denoting the height of the pyramid. The following d lines describe the contents of every level of the pyramid. Values are separated by one or more spaces. For every value v at the base of the pyramid (last row) -10000 v 10000. Missing values are denoted using a dash '-'. The last line of the file contains a single -1. which is not part of the data set. For each test case print one line of output in the form: k: result; where k is the test case number (starting at 1), and result is the sum at the top of the pyramid. If the pyramid wasn't solvable you print "Nor solvable". Separate your result from the colon (:) by a single space

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!