-
January 15th, 2013, 09:38 AM
#1
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.
-
January 15th, 2013, 09:40 AM
#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
-
January 15th, 2013, 03:55 PM
#3
Re: Convert this program into pyram1d
Originally Posted by wikki2013
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|