![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2008
Posts: 7
Rep Power: 0
![]() |
can anyone try to help me getting an output like this:
ull be able to input a number for example.. 12 and its output is like this... 12 11 10 9 8 7 6 5 4 3 2 1 11 10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1 .................... .................. ................... 3 2 1 2 1 1 i'm a noob programmer and can't figure how to start please help me thanks in advance... |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Re: arrays??
You'll need what's called a nested loop. You have one loop that counts down from 12 to 1, and inside that loop have another loop that counts down from the value of the iteration you're in to 1. The logic goes something like this:
loop from i = 12 to 1
loop from j = i to 1
print j
end loop
print newline
end loop |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Mar 2008
Posts: 7
Rep Power: 0
![]() |
Re: arrays??
ouch still can't follow... Ooble can u do the whole loop?
|
|
|
|
|
|
#4 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
Re: arrays??
You'll need to show some effort FengLing. What Ooble told you should be enough to get you started on some code. Where is your code?
|
|
|
|
|
|
#5 |
|
Newbie
Join Date: Mar 2008
Posts: 7
Rep Power: 0
![]() |
Re: arrays??
pls. help jst limit the number to 3
3 2 1 2 1 1 so that i can get a little idea... |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Mar 2008
Posts: 7
Rep Power: 0
![]() |
Re: arrays??
OpenLoop can u translate the sample of Ooble to C...
|
|
|
|
|
|
#7 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
Re: arrays??
|
|
|
|
|
|
#8 |
|
Newbie
Join Date: Mar 2008
Posts: 7
Rep Power: 0
![]() |
Re: arrays??
ok then what loop statement should i use?...
|
|
|
|
|
|
#9 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
Re: arrays??
a For loop will do.
|
|
|
|
|
|
#10 |
|
Expert Programmer
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 555
Rep Power: 5
![]() |
Re: arrays??
A 'for' loop is most appropriate for this situation. You will need two of them - a loop within a loop.
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| joining associative arrays | MiKuS | PHP | 2 | Sep 6th, 2007 2:20 AM |
| Confusion With Pointers and Arrays | JawaKing00 | C | 10 | Sep 14th, 2006 7:33 AM |
| Arrays or Vectors? | can342man | C++ | 2 | Apr 20th, 2006 3:57 PM |
| Arrays in PHP | MrMan9879 | PHP | 6 | Jan 12th, 2006 9:18 PM |
| Arrays | Gunman | C++ | 17 | Oct 20th, 2005 6:11 AM |