c++比较两个文件并删除重复的公共编号
c++ comparing two file and remove the duplicate common number
t尝试编写一个c++程序,该程序获取两个包含随机数的文件,并比较两个文件(文件1中的每个数字与文件2中的所有数字)
//open and read the two file "rno1.txt" and "rno2.txt".
ifstream inputfile1;
inputfile1.open("rno1.txt");
ifstream inputfile2;
inputfile2.open("rno2.txt");
bool found = false;
bool F = false;
int CList1[20]; //save the containt of file1.
int CList2[20]; //save the containt of file2.
int i=0,j=0;
int n1,n2;
//move the containt of file1 to the array.
while ( inputfile1 >> n1 && i < 20 )
{
CList1[i]= n1;
i++;
}
//move the containt of file2 to the array.
while ( inputfile2 >> n2 && j < 20 )
{
CList2[j]= n2;
j++;
}
inputfile2.close();
//comparing the common number between both files.
for ( int x=0 ; x<20 ; x++ )
{
for ( int y=0 ; y<20 ; y++ )
{
if ( CList1[x] == CList2[y] )
{ cout << CList1[x] << "n" ;
found = true; }
}
}
//checking if there is common numbers between both files or not!
if ( found == false )
{ cout << "There are NO common number!" << "n"; }
inputfile1.close();
inputfile2.close();
问题:
在打印公用编号之前,我想删除两个文件之间重复的公用编号。。
例如:
file1 file2
2 4
3 2
2 4
4 0
4 3
1 7
通用编号为:
2
3
2
4
4
4
4
我想要的结果是:
2
3
4
- 取两个列表中的所有数字,将它们转储到一个数组中
- 对数组进行排序
- 对数组进行步进处理,只有当数组不止一个时才打印出数字
相关文章:
- 将数组的地址分配给变量并删除
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- C/C++编译器通常会删除重复的库吗
- 从链接列表c++中删除一个项目
- C++如何通过用户输入删除列表元素
- 为什么在C++中使用私有复制构造函数与删除复制构造函数
- 是否需要删除包含对象的"pair"?
- 如何在自删除后将对象设置为nullptr
- 迭代时从向量和内存中删除对象
- 使用函数"remove"删除重复元素
- 如何从多映射中删除特定的重复项
- 运算符C++ "delete []"仅删除 2 个前值
- 删除指向指针的指针是运行时错误吗
- 将指针设置为"nullptr"并不能防止双重删除?
- 为什么示例代码访问IUnknown中已删除的内存
- 如何通过 getter 函数删除矢量的元素?
- 从数组中获取唯一编号,完全删除重复项
- c++比较两个文件并删除重复的公共编号
- 如何从单向链表中删除偶数编号的节点
- C++ 从字符串中删除偶数编号的单词