Print a pyramid where the last row contains all numbers

Assignment Help Computer Engineering
Reference no: EM132211142

Question :

Write a program pyramid.cpp that reads a positive odd whole number n and prints a pyramid where the last row contains all numbers from n down to 1 (i.e., descending order), the second to last row displays all numbers from n - 1 down to 2, the third to last row displays all numbers from n - 2 down to 3, etc.

The first row will contain only a single value, i.e. the middle value in the range, i.e. n down to 1.

Each successive row contains two more values than the previous row. This is the original problem , I WANT TO INVERSE the picture, here is my code, I don't know where is wrong? #include using namespace std;

int main(){

int n;

cout << "Enter n : ";

cin >> n;

int mid = (n+1)/2;

for(int i =1;i<=mid;i++){

for(int j=1;j<=i;j++){

cout << " ";}

int a=n;
int bb=n;
for(int h=bb;h>=1;h--){

if((a-i+1)>=10){

cout << (a-i+1)%10;}

else{ cout << a-i+1; }

a--; }

cout << endl;

bb = bb-2; }

return 0; }

The result runs the same as the original problem.

Reference no: EM132211142

Questions Cloud

Create an array with the number of rows and columns : Write a program which prompts the user to enter the number of rows and columns in a table.
How does remote access permission works : How does remote access permission works? What could interfere with the ability to access a user's system?
Write a program in python to convert a u.s. customary system : Write a program in PYTHON to convert a U.S. Customary System length in miles, yards, feet, and inches to Metric system length in kilometers, meters.
Associated with the programming language names : Briefly explain the "meanings" associated with the programming language names C++, Lisp, Prolog.
Print a pyramid where the last row contains all numbers : Write a program pyramid.cpp that reads a positive odd whole number n and prints a pyramid where the last row contains all numbers from n down.
What language supported data structure : Lists are also supported in Prolog. In C and C++, a list can be implemented using what language supported data structure?
Think for a moment about the telecommunication industry : Think for a moment about the telecommunication industry today and what it was just a few years ago, where are we headed?
Prints the three grades one per line in reverse order : Each grade is an integer number. Prints the three grades one per line in reverse order of input and labeled as Test 1, Test2, and Test3.
The best nursing program in the cal state system : If you're thesis or topic is "Cal State Los Angeles has the best nursing program in the Cal State system,"

Reviews

Write a Review

Computer Engineering Questions & Answers

  What are the key determinants of success and failure

What are the key determinants of success and failure for each system? As an architect, how would these determinants change your approach to concept formulation.

  Describe the proposed new database system

The final assignment for this course is an eight to ten page Final Project according to APA style. The purpose of the Final Project is for you to culminate.

  Determine the optimum fin spacing by natural convection

Reconsider Problem. Using EES (or other) software, investigate the effect of the length of the fins in the vertical direction on the optimum fin spacing.

  Describe and discuss at least two backup strategies

Describe and discuss at least two backup strategies. Discuss one of the most important things you will take from this course.

  Explain what you would do in a given situation

This case study provides you an opportunity to explain what you would do in a situation where your client is expecting you to provide guidance.

  Create an application that models a public library

Use Java to create an application that models a public library, where users can borrow books, put books on hold, etc.

  How do problems impact the information security field

Identify two to three key problems. Why do they exist? How do they impact the information security field? Who is responsible for them?

  Make a java application containing an array

design a JApplet with a JButton labeled "Who's number one?". When the user clicks the button, display your favorite sports team. Save the file as JNumberOne.java .

  Write a recursive function pattern that accepts one argument

Write a recursive function pattern that accepts one argument, an integer that is a power of 2, and prints the following patterns.

  Explain the social engineering concerns in detail

Imagine a scenario where Jane, an administrative employee of a company, receives a call from James, the company's security administrator.

  Consider whether there should be a hard

normally , we use normalization techniques a database. using the bowen et al. (2004) article, discuss the disadvantages of normalizing the database to a high degree of normalization.

  Create programs to calculate given equation

create programs to calculate (A+3)*B+C*5. You can assume that memory-memory operations are allowed.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd