Convert this program into pyram1d
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Convert this program into pyram1d

  1. #1
    Join Date
    Jan 2013
    Posts
    2

    Post Convert this program into pyram1d

    Hi there,
    I have this program here I have written recently. Now I am trying very hard to convert this into a pyramid. I am not able to make any logic of it. I hope you can help me out. Here is my code:

    #include <iostream>
    #include <conio.h>
    using namespace std;
    void main()
    {
    int number, temp;
    cout << "Enter a number: ";
    cin >> number;
    temp = number;
    for (int i = 1 ; i <= number; i++)
    {
    for (int j = 1; j<=temp; j++)
    cout << j;
    temp--;
    cout << endl;
    }
    getch();
    }

    Output:

    12345
    1234
    123
    12
    1

    I want the output of this program to be in a pyramid. Like;

    1 2 3 4 5
    1 2 3 4
    1 2 3
    1 2
    1
    I hope you can help me out. Thanks for your time.

  2. #2
    Join Date
    Jan 2013
    Posts
    2

    Re: Convert this program into pyram1d

    Sorry , i have written wrong above , i want the output in the pyramid

    1 2 3 4 5
    1 2 3 4
    1 2 3
    1 2
    1

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,475

    Re: Convert this program into pyram1d

    Quote Originally Posted by wikki2013 View Post
    Code:
    Output:
    
    12345
    1234
    123
    12
    1
    I want the output of this program to be in a pyramid. Like;
    Code:
                  1 2 3 4 5
                   1 2 3  4
                     1 2 3
                       1 2
                         1
    I hope you can help me out. Thanks for your time.
    If you want to have the formatted post here in the Forum then, please, use Code tags!
    The same Code tags you have to use around your code snippets. Otherwise your code in unreadable!
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center