1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
using Vec = std::vector<int>;
using Vec2D = std::vector<Vec>;
int main () {
// 2d vector of maintenance codes codes can range from 1 to 17
Vec2D mcvec {{2, 9, 12, 14},
{1, 7, 9, 16},
{2, 8, 10, 17}, // Start Counting mcvec[2].begin()
{3, 7, 11, 15},
{1, 10, 14, 15},
{4, 5, 12, 17},
{1, 9, 15, 17},
{4, 11, 15, 16},
{2, 10, 12, 14},
{4, 7, 11, 12}, // End Counting mcvec[9].end()
{2, 5, 11, 15}};
// vector of pairs <key=maintenance code, value=counter for # of occurrences of code
vector<pair<int, int>> mcprvec { {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0},
{7, 0}, {8, 0}, {9, 0}, {10, 0}, {11, 0}, {12, 0},
{13, 0}, {14, 0}, {15, 0}, {16, 0}, {17, 0} };
int x { 2 }; // Used for starting row [index] of mcvec
int y { 10 }; //Used for ending row [index] of mcvec
for ( int i { x}; mcvec[i] < mcvec[y] ; ++i ) // Not sure if these 2 FOR loops (lines 32, 33)are set up
for ( int j {y}; j < mcvec[i].size() ; ++j ) // correctly to iterate through the mcvec 2dvector.
// HERE i'm really stuck! Not sure how to increase counter in mcprvec for when the key is present.
return 0;
}
|