如何比较两个word文档内容是否相同

  1. 准备两个要比较的文档 test1.docx 和 test2.docx。

     

  2. 打开word->审阅->比较。

     

  3. 操作完步骤2会出现一个弹窗,选择原文档和修订的文档,点击确定。

     

  4. 此时会在word左侧出现比较结果文档,右侧为进行比较的两个初始文档;结果文档中标下划线的即为不同之处,虚线指向为内容变化说明。

     

  5. 修改test2.docx内容,使之与test1.docx内容一致,按上述步骤比较两个文档,则会弹窗提示两个文档无差别。

     

转载于:https://www.cnblogs.com/qdwyy/p/9166865.html

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用C++的STL库中的set容器来比较两个文件的内容,并输出相同内容。具体步骤如下: 1. 打开两个文件,并将它们的内容分别读入两个字符串中。 2. 将第一个字符串中的每个单词插入到一个set容器中。 3. 遍历第二个字符串中的每个单词,如果该单词存在于set容器中,则说明这两个文件有相同内容,将该单词输出。 下面是示例代码: ```c++ #include <iostream> #include <fstream> #include <string> #include <set> using namespace std; int main() { ifstream file1("file1.txt"); ifstream file2("file2.txt"); string str1((istreambuf_iterator<char>(file1)), istreambuf_iterator<char>()); string str2((istreambuf_iterator<char>(file2)), istreambuf_iterator<char>()); set<string> wordSet; string word = ""; for (int i = 0; i < str1.length(); i++) { if (str1[i] != ' ' && str1[i] != '\n') { word += str1[i]; } else { wordSet.insert(word); word = ""; } } wordSet.insert(word); word = ""; for (int i = 0; i < str2.length(); i++) { if (str2[i] != ' ' && str2[i] != '\n') { word += str2[i]; } else { if (wordSet.find(word) != wordSet.end()) { cout << word << " "; } word = ""; } } if (wordSet.find(word) != wordSet.end()) { cout << word << " "; } file1.close(); file2.close(); return 0; } ``` 其中,file1.txt和file2.txt是需要比较两个文件。在上面的示例代码中,我们将文件内容读入到两个字符串中,然后遍历第一个字符串,将每个单词插入到set容器中。接着,我们遍历第二个字符串,如果该单词存在于set容器中,则说明这两个文件有相同内容,将该单词输出即可。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值