求數組中所有小於100 的下標

#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);
}
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章