Declare a vector of integers named vec
and initialize the vector to 10,20,30,40, and 50
Modify the first element of the vector to be 100
and modify the last element of the vector to be 1000
.
The final vector should then be 100
, 20, 30, 40, and 1000
.
You can find my solution by clicking on the solution.txt file on the left pane. But please make sure you give it a go yourself first, and only check the solution if you really get stuck.
#include
#include "gtest/gtest.h"
#include "helpers/iohelper.h"
std::vector use_vector();
namespace {
class Evaluate : public ::testing::Test {};
TEST_F(Evaluate, ExampleTest) {
std::vector r {100,20,30,40,1000};
std::vector v = use_vector();
EXPECT_EQ(r, v) << "Your vector should be {100, 20, 30, 40, 1000}";
}
} // namespace
#include
using namespace std;
vector use_vector() {
//----WRITE YOUR CODE BELOW THIS LINE----
std::vector vec {10, 20, 30, 40, 50};
vec.at(0) = 100;
vec.at(4) = 1000;
//----WRITE YOUR CODE ABOVE THIS LINE-----
//----NO NOT MODIFY THE CODE BELOW THIS LINE----
return vec;
}
//