C++ 比较并查找C+中的重复数组+;

C++ 比较并查找C+中的重复数组+;,c++,arrays,duplicates,C++,Arrays,Duplicates,Higuys,我在做一个小程序,它的部分功能是找到重复的数组 假设我在mem[100][4] 在temp[4]中还有另外一组4个数字等待存储 程序检查mem[100][4]中是否有相同的设置, 如果否,则temp[4]集将存储为mem[numR][4] numR表示mem数组中的总条目,也是我的程序的主要结果 但输出为0或包含重复项。有人知道我的代码有什么问题吗 void Cord::checkDup(){ int j, k, z=0; int swap = 0

Higuys,我在做一个小程序,它的部分功能是找到重复的数组

假设我在
mem[100][4]

temp[4]
中还有另外一组4个数字等待存储

程序检查
mem[100][4]
中是否有相同的设置, 如果否,则
temp[4]
集将存储为
mem[numR][4]

numR表示mem数组中的总条目,也是我的程序的主要结果

但输出为0或包含重复项。有人知道我的代码有什么问题吗

 void Cord::checkDup(){
        int j, k, z=0;
        int swap = 0;

        temp[0] = i;
        temp[1] = x;
        temp[2] = y;
        temp[3] = c;

        //Ascending sort
        /* code not shown here*/


        //Check for duplicate
        for (j = 0; j < (numR-1);j++){
                if(
                        (mem[j][0] == temp[0]) &&
                        (mem[j][1] == temp[1]) &&
                        (mem[j][2] == temp[2]) &&
                        (mem[j][3] == temp[3])
                    ){
                        numR--; /* the reason behind this is because I first assumed it is a valid entry and incremented numR by 1 before the checking*/
                        return;

                }else{
                    continue;
                }
        }
        mem[numR - 1][0] = temp[0];
        mem[numR - 1][1] = temp[1];
        mem[numR - 1][2] = temp[2];
        mem[numR - 1][3] = temp[3];


    }
void Cord::checkDup(){
int j,k,z=0;
整数交换=0;
温度[0]=i;
温度[1]=x;
温度[2]=y;
温度[3]=c;
//升序排序
/*此处未显示代码*/
//检查有无重复
对于(j=0;j<(numR-1);j++){
如果(
(mem[j][0]==temp[0])&&
(mem[j][1]==temp[1])&&
(mem[j][2]==temp[2])&&
(mem[j][3]==temp[3])
){
numR--;/*这背后的原因是,我首先假设它是一个有效条目,并在检查之前将numR增加1*/
回来
}否则{
持续
}
}
mem[numR-1][0]=temp[0];
mem[numR-1][1]=temp[1];
mem[numR-1][2]=temp[2];
mem[numR-1][3]=temp[3];
}

你可以把
mem
a
std::set
变成一个
a
std::set
并完全放弃搜索重复项。什么是i,x,y,c?他们是绳索对象的成员吗?您正在搜索任何出现的{i,x,y,c},但不搜索重复项。