Mar 29, 2014 at 7:32pm UTC
how to get this output but in same level with explanation please
1 2 3 4 5 6 7 8 9 10
*
***
*****
*******
*********
*
***
*****
*******
*********
Last edited on Mar 29, 2014 at 7:35pm UTC
Mar 29, 2014 at 7:51pm UTC
What code do you have so far?
We're not going to write your code for you.
Mar 29, 2014 at 7:56pm UTC
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
for (int a = 1; a <= n; a++)
{
for (int b = 1; b <= a; b++)
{
cout<<"*"<<" ";
}
cout<<endl;
}
for (int y = 1; y <= n; y++)
{
for(int r = n-y; r>0; r--)
{
cout<<" ";
}
for(int x = 1; x <= y; x++)
{
cout<< "*" <<" ";
}
cout << endl;
}
return 0;
}
Mar 29, 2014 at 7:57pm UTC
Sorry for not writing the code in the question and I want only how to make them at the same level and thank you for your reply
Mar 30, 2014 at 1:49am UTC
Instead of having two separate outer for loops to control 2 sets of rows, you'll have one outer for loop that controls a single set of rows. The numbers for the pattern on the right have to adjust for no longer starting at the very left side of the screen.