求数组中所有小于100 的下标

来源:互联网 发布:徐州淘宝运营 编辑:程序博客网 时间:2024/05/16 16:22

#include <vector>
using namespace std;

int main()
{

int arr[11] = {1, 700, 0, 8,   3,  4,  2, 8, 7, 0, -1};

std::vector<int> vcIndices;

for (int i = 0; i < 11; i++)
{
if (arr[i] < 100)
{
vcIndices.push_back(i);
}
}

std::vector<int>::iterator it;
for(it = vcIndices.begin(); it != vcIndices.end(); ++it)
{
printf("%4d", *it);
}
}