473,385 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Programming Question Help

Probably a very easy question for most of you guys out there but I
simply can't get to figure out how to do this

Suppose that I have an unknown number of items (A,B,C,etc...) and each
item contain an unknown number of elements(e.g A1,A2,A3,A4, B1,B2, C1)

How would I go around writing a java code to give me the possible
combinations(in that case 8)of A B and C in that order?
i.e.
A1 B1 C1
A1 B2 C1
A2 B1 C1
A2 B2 C2
A3 B1 C1
A3 B2 C2
A4 B1 C1
A4 B2 C2

Help pls
Jul 17 '05 #1
2 1701
Joe
In article <96**************************@posting.google.com >,
cy****@hotmail.com says...
Probably a very easy question for most of you guys out there but I
simply can't get to figure out how to do this

Suppose that I have an unknown number of items (A,B,C,etc...) and each
item contain an unknown number of elements(e.g A1,A2,A3,A4, B1,B2, C1)

How would I go around writing a java code to give me the possible
combinations(in that case 8)of A B and C in that order?
i.e.
A1 B1 C1
A1 B2 C1
A2 B1 C1
A2 B2 C2
A3 B1 C1
A3 B2 C2
A4 B1 C1
A4 B2 C2

Help pls


One way is to use two loops. The outer loop steps through the number of
items and the inner loop steps through the elements in each item. If you
cannot programmatically determine the number of items or elements prior
to entering the loop, then an iterator is more useful. Alternatively, you
can place a "sentinel" value (i.e. null) at the end of the list and,
instead of loopping use while (!null){ } .



--

Fuck George W. Bush!!!
Jul 17 '05 #2
The problem is the number of items and the number of elements can only
be determined at runtime. anyone care give a short pseudo code of a
possible solution pls? thx

Joe <sf***@spamcop.net> wrote in message
One way is to use two loops. The outer loop steps through the number of
items and the inner loop steps through the elements in each item. If you
cannot programmatically determine the number of items or elements prior
to entering the loop, then an iterator is more useful. Alternatively, you
can place a "sentinel" value (i.e. null) at the end of the list and,
instead of loopping use while (!null){ } .

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mark | last post by:
Hello. I am new to programming and Python and was wondering if someone could help get me started. I picked Python to start learning to prgram because of some things I have read about it (easy to...
2
by: Mike Maxwell | last post by:
(apologies if this is not the right place to ask--suggestions on a more appropriate venue welcome!) I would like to do some literate programming-type writing, probably using the DocBook format. ...
12
by: G. | last post by:
Hi all, During my degree, BEng (Hons) Electronics and Communications Engineering, we did C programming every year, but I never kept it up, as I had no interest and didn't see the point. But now...
3
by: user | last post by:
Hi all, At the outset, I regret having to post this slightly OT post here. However, I strongly feel that people in this group would be the best to advise me on my predicament. I am working as...
26
by: Kanthi Kiran Narisetti | last post by:
Hi ALL, I am new to C and programming . I need suggestions for the IDE to be used as a begginer and should I start on Windows or Linux ?? I am also looking for resources for C programming on...
42
by: Kevin Spencer | last post by:
Is it just me, or am I really observing a trend away from analysis and probem-solving amongst programmers? Let me be more specific: It seems that every day, in greater numbers, people are coming...
25
by: Dave | last post by:
I want to spend two minutes on my soapbox. I love C#. I am so productive in it it's ridiculous. But it's so easy to write code that uses poor design principles. Example: just making...
20
by: Mike | last post by:
Hi all, I am cramming for an technical interview about C++ and programming... I believe there will be problems on data-structures and algorithms... could anybody recommend some online...
13
by: 1jasong | last post by:
Hello I am new to programming and want to know what is a good free compiler is. I am asking this because there are so many of them and I just want to start programming also a good website for...
139
by: Joe Mayo | last post by:
I think I become more and more alone... Everybody tells me that C++ is better, because once a project becomes very large, I should be happy that it has been written in C++ and not C. I'm the only...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.