Re: partition numbers in four terms

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On May 27, 6:43 pm, "Pascal" <scalpaSansS...@xxxxxxxxxxx> wrote:
hello all

I try to find a class able to store in an array or a collection or something
like that (I don't know what will be the best practice) all the different
combinations of the partitions of any integer in four terms :
exemple :

8= (5 + 1 + 1 + 1)
= ( 4 + 2 + 1 + 1)
= ( 3 + 2 + 2 + 1 )
= ( 3 + 3 + 1 +1) etc.

( 4 + 2 + 1 + 1) is not different of ( 2 + 1 + 4 + 1)

I found a code on the net but in java :http://bytes.com/topic/c/answers/869529-print-all-combinations-number...
Does someone knows something in java and vb, so he could translate it for
me.... I am not very handy in programmation, just make some stuff for my
young pupils.

Thanks in advance

public class Partition {

    private static void printPartition(int[] p, int n) {
  if (n != 4) return; // bail out
        for (int i= 0; i < n; i++)
            System.out.print(p[i]+" ");
        System.out.println();
    }

    private static void partition(int[] p, int n, int m, int i) {

        if (n == 0)
            printPartition(p, i);
        else
            for (int k= m; k > 0; k--) {
                p[i]= k;
                partition(p, n-k, n-k, i+1);
            }
    }

    public static void main(String[] args) {

        partition(new int[6], 6, 6, 0);
    }}

--

Simply that is an order partition
.



Relevant Pages

  • Re: How to store a large amount of 3D data points in Java?
    ... >>None of which would be a problem if you could store ints in a Java ... > With 1.5 autoboxing you can, even if it is implemented with objects. ... ArrayList does array copy for resizing. ...
    (comp.lang.java.programmer)
  • Reading in text file and comparing records
    ... How do I read in a text file into Java? ... i.e. one line at a time and store ... of the elements in the large array, how do I perform a comparison of the two ... arrays which finds any elements in the large array which are missing from ...
    (comp.lang.java.programmer)
  • Re: sfc/scannow - stops at 76 %
    ... CSI 00000141 Cannot repair member file ... neutral, TypeName neutral, PublicKey neutral in the store, hash mismatch ... What happened when you removed Acer? ... Is there not a hidden partition to factory ...
    (microsoft.public.windows.vista.general)
  • Re: sfc/scannow - stops at 76 %
    ... CSI 00000141 Cannot repair member file ... neutral, TypeName neutral, PublicKey neutral in the store, hash mismatch ... What happened when you removed Acer? ... Is there not a hidden partition to factory ...
    (microsoft.public.windows.vista.general)
  • Re: [opensuse] software RAID vs BIOS RAID
    ... I recently set up a server with four 1 TB drives, ... with LVM on RAID 4. ... I created a 2 GB partition to hold /boot and used ... create a raid1 array using all the partition-1's, ...
    (SuSE)