如何在C ++中逐个元素地比较两个向量的相等性? [英] How to compare two vectors for equality element by element in C++?
本文介绍了如何在C ++中逐个元素地比较两个向量的相等性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么方法可以比较两个向量吗?
Is there any way to compare two vectors?
if (vector1 == vector2)
DoSomething();
注意:当前,这些向量未排序并且包含整数值。
Note: Currently, these vectors are not sorted and contain integer values.
推荐答案
检查 std :: mismatch
的C ++方法。
Check std::mismatch
method of C++.
比较向量已经在 DaniWeb论坛上进行了讨论,并已回答。
comparing vectors has been discussed on DaniWeb forum and also answered.
检查下面的SO帖子。对您有帮助。他们用不同的2方法也取得了相同的效果。
Check the below SO post. will helpful for you. they have achieved the same with different-2 method.
这篇关于如何在C ++中逐个元素地比较两个向量的相等性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文