Dec 13, 2014 at 9:18pm UTC
how can I get the following result
1 2 3 4 5 6 7 6 5 4 3 2 1
1 2 3 4 5 6 * 6 5 4 3 2 1
1 2 3 4 5 * * * 5 4 3 2 1
1 2 3 4 * * * * * 4 3 2 1
1 2 3 * * * * * * * 3 2 1
1 2 * * * * * * * * * 2 1
1 * * * * * * * * * * * 1
code]
#include <iostream>
int main ()
{
for(int i=0;i<=12; i++)
?
?
?
}
[/code]
Dec 13, 2014 at 9:56pm UTC
You're going to need two for loops.
Dec 13, 2014 at 10:39pm UTC
but how can I use....
kindly help I am got confused..
I am a beginner...
Dec 13, 2014 at 10:43pm UTC
Look at the pattern. You iterate up, then you iterate down and repeat until you run out of numbers. Alternatively you can have a string and modify it. Though that wouldn't be as modular in design.
Last edited on Dec 13, 2014 at 10:45pm UTC
Dec 13, 2014 at 11:12pm UTC
It's not your compiler not working. The code does not make sense and has several syntax errors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
using namespace std;
int main()
{
for (int h = 7;h<=0;h++)
{
for (int i=0;i<=7;i++)
{
for (int k=i;k<0;k+=2)
{
cout<<"*" ;
}
for (int j=6;j>0;j--)
}
Last edited on Dec 13, 2014 at 11:12pm UTC