Vector 容器如何删除指定数据有关问题。不清楚该数据在vector里的索引

Vector 容器怎么删除指定数据问题。不清楚该数据在vector里的索引
vector<int> v_int;
现在我只知道容器里有三个值,分别为100,200,300,现在我要删除200,但我不知道其索引,就不能用erase函数了,求解答怎么获得指定数据的索引,然后调用erase函数啊

------解决方案--------------------
引用:
Quote: 引用:

Vector 容器如何删除指定数据有关问题。不清楚该数据在vector里的索引for循环遍历一下呗
或者STL里的find类算法也行

还以为有直接的函数可以得到呢,还是要for循环来找啊,费时间,怎么没有个函数根据数据得到索引呢   呵呵

可以考虑改用map
------解决方案--------------------
Vector 容器如何删除指定数据有关问题。不清楚该数据在vector里的索引
find ?
遍历?
Vector 容器如何删除指定数据有关问题。不清楚该数据在vector里的索引
请用remove

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int
main(int argc, char *argv[])
{
    vector<int> vi;
    vector<int>::const_iterator it;

    vi.push_back(100);
    vi.push_back(200);
    vi.push_back(300);

    for (it = vi.begin(); it != vi.end(); ++it) {
        cout << *it << " ";
    }
    cout << endl;

    vi.erase(remove(vi.begin(), vi.end(), 200), vi.end());

    for (it = vi.begin(); it != vi.end(); ++it) {
        cout << *it << " ";
    }
    cout << endl;

    return 0;
}