0

I'm trying to count unique numbers in an array that is already sorted with bubble-sort method.

I want to store the result in a 2D-array in LabVIEW.

I have tried many things, but for some reason it doesn't work.

This is my code:

// COUNT NUMBERS
int colorCount[256][2];

int m, n;
int getal;
int first = 1;
int prevG, prevP;
int tel = 0;
for (m = 0 ; m<12; m++){

    getal = Dnum[m];

    if( first == 1){

        colorCount[0][0] = getal;
        colorCount[0][1] = 1;
        first = 0;
        prevP = 0;
    }
    else{
        if( prevG == getal){
            tel = colorCount[prevP][1];
            colorCount[prevP][1] =  tel++;     
        } 
        else{
            prevP++;
            colorCount[prevP][0] = getal;
            colorCount[0][1] = 1;
        }
    }
    prevG = getal;

}
Jakub Czaplicki
  • 1,787
  • 2
  • 28
  • 50
Sharpless512
  • 3,062
  • 5
  • 35
  • 60

1 Answers1

0

The last line with colorCount[0][1] = 1; is incorrect. That line should be

colorCount[prevP][1] = 1;
banuj
  • 3,080
  • 28
  • 34