# Thread: Eliminating duplicate values from a 20x2 array

1. ## Eliminating duplicate values from a 20x2 array

hi guys, i'm REALLY new to C programming, and have created a few basic programs, but this is one problem thats really stumped me, and thats how to eliminate multiple values from a 2D array. Basically, the user enters 20 numbers, and those are entered into the first column of the array. Then, i somehow have to eliminate the duplicate values in the first column and copy them into the second. Thats part of whats stumping me, but the other part is then with the second array, sorting them based on even/odd/negative values. The input is integer only, but the problem is that i can't use a threshold value in the second array to indicate whether a duplicate was found, as it would then throw off the sorting of the neg/even/odd elements.

eg)
Code:
``` for (i=0;i<ROWS;i++){

for (j=0;j<ROWS;j++){

if (matrix[j[!=matrix[i]){

matrix[i]=-1
}
}
}```
The above would not be valid...I've searched the forums and gotten a few results, but nothing i can really use. If someone could give me a hand, i would appreciate it!

2. For each row, check every filled column of the second column. If the number already exists, don't copy it:
Code:
```for ( i = 0; i < ROWS; i++ ) {
for ( j = 0; j < k; j++ ) {
if ( a[i][0] == a[j][1] )
break;
}

if ( j == k )
a[k++][1] = a[i];
}```
There's really no need to do anything more sophisticated since you're only working with 20 numbers.

3. ## Thank You!

That worked great! Excellent man!