Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 23rd, 2008, 8:56 AM   #1
FengLing
Newbie
 
Join Date: Mar 2008
Posts: 7
Rep Power: 0 FengLing is on a distinguished road
Question arrays??

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...
FengLing is offline   Reply With Quote
Old Mar 23rd, 2008, 8:59 AM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 23rd, 2008, 9:22 AM   #3
FengLing
Newbie
 
Join Date: Mar 2008
Posts: 7
Rep Power: 0 FengLing is on a distinguished road
Re: arrays??

ouch still can't follow... Ooble can u do the whole loop?
FengLing is offline   Reply With Quote
Old Mar 23rd, 2008, 10:21 AM   #4
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
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?
OpenLoop is offline   Reply With Quote
Old Mar 23rd, 2008, 10:35 AM   #5
FengLing
Newbie
 
Join Date: Mar 2008
Posts: 7
Rep Power: 0 FengLing is on a distinguished road
Re: arrays??

pls. help jst limit the number to 3

3 2 1
2 1
1

so that i can get a little idea...
FengLing is offline   Reply With Quote
Old Mar 23rd, 2008, 10:46 AM   #6
FengLing
Newbie
 
Join Date: Mar 2008
Posts: 7
Rep Power: 0 FengLing is on a distinguished road
Re: arrays??

OpenLoop can u translate the sample of Ooble to C...
FengLing is offline   Reply With Quote
Old Mar 23rd, 2008, 10:49 AM   #7
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
Re: arrays??

Quote:
Originally Posted by FengLing View Post
OpenLoop can u translate the sample of Ooble to C...
No I can't. What I can translate is what I said earlier, WE DONT DO YOUR HOMEWORK FOR YOU. Read the rules and show some effort, any effort past posting a question.
OpenLoop is offline   Reply With Quote
Old Mar 23rd, 2008, 11:24 AM   #8
FengLing
Newbie
 
Join Date: Mar 2008
Posts: 7
Rep Power: 0 FengLing is on a distinguished road
Re: arrays??

ok then what loop statement should i use?...
FengLing is offline   Reply With Quote
Old Mar 23rd, 2008, 12:15 PM   #9
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
Re: arrays??

a For loop will do.
OpenLoop is offline   Reply With Quote
Old Mar 23rd, 2008, 12:21 PM   #10
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 574
Rep Power: 5 Benoit is on a distinguished road
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
Benoit is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
joining associative arrays MiKuS PHP 2 Sep 6th, 2007 3:20 AM
Confusion With Pointers and Arrays JawaKing00 C 10 Sep 14th, 2006 8:33 AM
Arrays or Vectors? can342man C++ 2 Apr 20th, 2006 4:57 PM
Arrays in PHP MrMan9879 PHP 6 Jan 12th, 2006 10:18 PM
Arrays Gunman C++ 17 Oct 20th, 2005 7:11 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:16 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC