![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Location: mars
Posts: 2
Rep Power: 0
![]() |
Nested Loop Question
can anyone help me on how do i make this output:* ** *** **** ***** i know thats simple but i cant seem to figure it out using the nested loop. my output just looks like this: * ** ** *** ***** Perhaps if anyone could help me. I could already figure out how to do this: 1 1 2 1 2 3 1 2 3 4 1 2 3 1 2 1 |
|
|
|
|
|
#2 | |
|
Hobbyist Programmer
Join Date: Dec 2004
Location: a cardboard box
Posts: 118
Rep Power: 4
![]() |
Quote:
for (int i=1; i <= 5; i++){
for (int j=i; j > 0; j--)
cout << "* ";
cout << endl;
}
__________________
... |
|
|
|
|
|
|
#3 | |
|
Newbie
Join Date: Feb 2005
Location: mars
Posts: 2
Rep Power: 0
![]() |
Thanks!!! That was really a great help. Anyway here's the code i use in making this output:Quote:
for(a=1;a<=5;a++)
{
for(b=a;b>=1;b--)
printf("\t%d",a-b+1);
printf("\n");
}
for(c=1;c<=4;c++)
{
for(d=c;d<=4;d++)
printf("\t%d",d-c+1);
printf("\n");
}
getch();
} |
|
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Dec 2004
Location: a cardboard box
Posts: 118
Rep Power: 4
![]() |
No problem. I just wish life was this simple.
__________________
... |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|