View previous topic :: View next topic |
Author |
Message |
MFBaba Beginner

Joined: 24 Nov 2004 Posts: 8 Topics: 4
|
Posted: Thu Oct 15, 2009 3:45 pm Post subject: Permutation logic in COBOL |
|
|
I want to perform a Permutation operation on the values entered by a user and provide as an output all the possible combination of the values.
eg. if user inputs A, B and C all possible output combinations would be (3! = 6): ABC,ACB,BCA,BAC,CAB and CBA
The maximum inputs the user can give is upto 10 values.
I want to use an internal array to store all possible combinations. Would it be better to declare a big array that can work for 10 values or use OCCURS DEPENDING ON clause to create an array based on the number of values input by the user? Any suggestions in this regard would be appreciated. |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Thu Oct 15, 2009 4:07 pm Post subject: |
|
|
1. remember a COBOL Interal table defined as occurs 1000 times and an ODO 1 to 1000 both allocate the same space - 1000 items.
2. depends on how you are going to handle the tables and your algorithm to develop the permutations.
Unless you are - writing variable length records
- using SEARCH ALL
your code will be basically the same. _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Oct 15, 2009 4:47 pm Post subject: Re: Permutation logic in COBOL |
|
|
MFBaba wrote: | The maximum inputs the user can give is upto 10 values.
I want to use an internal array to store all possible combinations. |
Just before you venture beware that
You are going to define an array of 10 bytes for that number? Good Luck getting the storage and generating the output
Kolusu |
|
Back to top |
|
 |
|
|