我是 C++ 和向量的新手,一直在尝试尝试一些 STL 函数,我想知道这怎么不起作用。我猜是因为我的第一个和最后一个位置,它们不允许是整数吗?
#include <cstdlib>
#include <vector>
#include <iostream>
using namespace std;
/*
*
*/
int main() {
const int lowest = 10;
const int highest = 99;
vector<int> scramble;
for (int i = 0; i < 20; i++){
scramble.push_back(lowest + rand() % (highest - lowest + 1));
cout << scramble.at(i) << endl;
}
int first = 0;
int last = 19;
cout << "The maximum value is: " << max_element(first, last);
}