vs出错dev-c++通过
比较两个vector#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector<int> vec1,vec2;
int val;
cout << "Enter the two vectors(-1 to end):" << endl;
cin >> val;
while ( val != -1 ) {
vec1.push_back(val);
cin >> val;
}
cin >> val;
while ( val != -1 ) {
vec2.push_back(val);
cin >> val;
}
if ( vec1.size() != vec2.size() )
cout << "Not equal" << endl;
else if ( vec1.size() == 0 )
cout << "Equal" << endl;
else
{
vector<int>::iterator iter1,iter2;
iter1 = vec1.begin();
iter2 = vec2.begin();
while ( *iter1 == *iter2 && iter1 != vec1.end() && iter2 != vec2.end() ) {
++iter1;
++iter2;
}
if ( iter1 == vec1.end() )
cout << "Equal" << endl;
else
cout << "Not equal" <<endl;
}
return 0;
}
此程序编译通过,在visual studio 2005中调试出错,但在dev-c++5中调试成功,不知为什么,望高手赐教?