Question-2: A pyramids are discovered, each has a triangular base with equal sides. An n meters high pyramid is constructed by forming n layers of triangles using Im' cubical stones. Then layers are stacked on top of cach other. The first layer is the triangle with n meters base, on top, n-l meters base, until the top level which has only I stone. You are asked to calculate the number of stones needed to build a pyramid with the height n. WAIT! We just discovered that some pyramids have a secret room inside. This room is also of the same shape and structure as the pyramid with m layers of stones removed. In order for the room to be secret, m

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
C++
Question-2:
A pyramids are discovered, each has a triangular base with equal sides. An n meters high
pyramid is constructed by forming n layers of triangles using Im' cubical stones. Then layers are
stacked on top of each other. The first layer is the triangle with n meters base, on top, n-1 meters
base, until the top level which has only I stone. You are asked to calculate the number of stones
needed to build a pyramid with the height n.
WAIT! We just discovered that some pyramids have a secret room inside. This room is also of
the same shape and structure as the pyramid withm layers of stones removed. In order for the
room to be secret, m<n-2.
.
Figure I. (a) 6 layers of stones, and (b) 6 meters high pyramid.
Example
The total number of stones needed to build a 6 meters high pyramid is
- (1+2+3+4+5+6)( 1+2+3+4+5)+ (1+2+3+4)+ (1+2+3)+ (1+2)+ 1
- 21 + 15 + 10 + 6+3+1-56.
If this pyramid has a 2 meters high secret room, then the total number of stones needed is 56 - 4
- 52.
Input
You have to read data from input file named, "input.txt". Each input has two integers, the first
represents the pyramid height n, and second represents the secret room height m. Input is
terminated by a sequence having n -0, m -0 which should not be processed.
Isns 2000000000, 0 Sms n-2
Output
You have to write output to the output file named, "output.txt". For each sequence, you are to
output one line, containing the number of stones needed
Input.txt
Output.txt
6.
56
6
.
55
6 2
52
36
4.
100 1
171699
S. Eiles to Submit
Files you must submit:
CashierSystem.cpp
Pyramid.cpp
Note:
• Working with friends is highly encouraged, and may share ideas However no sharing of code. There
are programs that can check the program's similarity, and I can see who are copying programs.
What is cheating in Programming?
When you have someone write your code.
When someone is sitting beside you, telling you what to code without you understanding
Finding code online and copying it into your program without understanding how it works
How to avoid cheating in Programming:
• Discuss about the assignment without showing your code.
Explain the concepts verbally or graphically to your friend.
Transcribed Image Text:Question-2: A pyramids are discovered, each has a triangular base with equal sides. An n meters high pyramid is constructed by forming n layers of triangles using Im' cubical stones. Then layers are stacked on top of each other. The first layer is the triangle with n meters base, on top, n-1 meters base, until the top level which has only I stone. You are asked to calculate the number of stones needed to build a pyramid with the height n. WAIT! We just discovered that some pyramids have a secret room inside. This room is also of the same shape and structure as the pyramid withm layers of stones removed. In order for the room to be secret, m<n-2. . Figure I. (a) 6 layers of stones, and (b) 6 meters high pyramid. Example The total number of stones needed to build a 6 meters high pyramid is - (1+2+3+4+5+6)( 1+2+3+4+5)+ (1+2+3+4)+ (1+2+3)+ (1+2)+ 1 - 21 + 15 + 10 + 6+3+1-56. If this pyramid has a 2 meters high secret room, then the total number of stones needed is 56 - 4 - 52. Input You have to read data from input file named, "input.txt". Each input has two integers, the first represents the pyramid height n, and second represents the secret room height m. Input is terminated by a sequence having n -0, m -0 which should not be processed. Isns 2000000000, 0 Sms n-2 Output You have to write output to the output file named, "output.txt". For each sequence, you are to output one line, containing the number of stones needed Input.txt Output.txt 6. 56 6 . 55 6 2 52 36 4. 100 1 171699 S. Eiles to Submit Files you must submit: CashierSystem.cpp Pyramid.cpp Note: • Working with friends is highly encouraged, and may share ideas However no sharing of code. There are programs that can check the program's similarity, and I can see who are copying programs. What is cheating in Programming? When you have someone write your code. When someone is sitting beside you, telling you what to code without you understanding Finding code online and copying it into your program without understanding how it works How to avoid cheating in Programming: • Discuss about the assignment without showing your code. Explain the concepts verbally or graphically to your friend.
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education