Checking for Duplicates

(Using C++) Alright so I got this problem to do in computer science from my teacher and I've got all of it working except for the checking for duplicates in a array (two dimensional but only in the columns). This is a snip of the part that checks for duplicates... Its not as "efficient" as it could be. I heard you could use for, for, if, for, then a do while. But I couldn't figure it out.

This is what I have now. I don't even know if it does work cuz currently I don't have the apmatrix library but know how to use it in class.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<iostream>
#include<iomanip>
#include<conio.h>
#include<time.h>
#include<cstdlib>
#include<string>
#include<apmatrix.h>
#include<vector>
using namespace std;
int R, Tickets, Cone, Ctwo, I;
apmatrix<int>Lotto(5,6);
vector<int>Rand(6);
void main()
{
//Checking for duplicates
for(R=0;R<Tickets;R++)
{
for(Cone=0;Cone<Lotto.numcols();Cone++)
{
for(Ctwo=0 ;Ctwo<Lotto.numcols();Ctwo++)
{
//Checks to keep it from getting in infinite loop cuz its obviously = to itself
if(Cone==Ctwo)
         Ctwo+=1;
//Checks if equal to another in the array of numbers.
if(Lotto[R][Cone]==Lotto[R][Ctwo])
{ do{
         Rand[Ctwo]=(rand()%50)+1;
         Lotto[R][Ctwo]=Rand[Ctwo];
         }while(Lotto[R][Cone]!=Lotto[R][Ctwo]);
}
//checks to see if equal to previously used numbers.
for(I=0;I<6;I++)
{
         if(Lotto[R][Ctwo]==Rand[I])
         {do{
         Rand[Ctwo]=(rand()%50)+1;
         Lotto[R][Ctwo]=Rand[Ctwo];
         }while(Lotto[R][Cone]!=Rand[I]&&Lotto[R][Ctwo]!=Lotto[R][Cone]);
         }
}
}
}
}
}

Also seems like I could add those two if statements together?
Topic archived. No new replies allowed.