标题:vs出错dev-c++通过
只看楼主
hongwu147
Rank: 1
等 级:新手上路
帖 子:47
专家分:0
注 册:2008-2-2
结帖率:100%
 问题点数:0 回复次数:1 
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中调试成功,不知为什么,望高手赐教?
搜索更多相关主题的帖子: val vector cin int 
2008-02-19 16:41
随心
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:12
帖 子:2577
专家分:250
注 册:2007-8-12
得分:0 
没有错误信息吗?你怎么不发上来?

天之道,利而不害。圣人之道,为而不争。信言不美,美言不信。善者不辩,辩者不善。知者不博,博者不知。
2008-02-19 19:02



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-200355-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.978074 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved