Question
#include #include #include #include using namespace std; int main() { int height; // rows int width; // columns string file; cout < < enter the
#include
int height; // rows int width; // columns string file;
cout << "enter the height of the map you wish to analyze" << endl; cin >> height; cout << "enter the width of the map you wish to analyze" << endl; cin >> width; //cout << "enter the name of the mountain you wish to analyze" << endl; //cin >> file;
vector
if (!myfile.is_open()) { cout << "Could not open file myfile" << endl; system("pause"); return 1; }
for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { myfile >> altVec[i][j]; //cout << "[ " << i << "][ " << j << "] = " << altVec[i][j] << endl; }
} myfile.close();
int max = -1; int min = 10000000000;
for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { if (altVec[i][j] > max) { max = altVec[i][j]; } if (altVec[i][j] <= min) { min = altVec[i][j]; }
} } double xmin = min; double xmax = max; double xheight = height; double xwidth = width; vector
So in this assignment we are supposed to take elevation readings from a 2d map in a .dat file. I was able to copy the data into my own 2d vector, calculate the max and min, and even calculating the shade of grey for each elevation point using the formula: ((exact elavation point-min)/(max-min))*255 . However I am struggling to understand this part: As you compute the shade of grey, store that value in three parallel vectors for R, G and B. Putting the same value for R, G and B will result in grey. The structure of the vector should mirror the vector with the elevation data. I have the values for shades of gret, but I do not understand whar it means to put those points into another vector. Above is my current code:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started