So...I think i got the basic basics down and im trying to move on to dimensonal arrays. I've read about it so i have teh basic idea down.
Im trying to make a highscoresystem and have gotn this far. But i want my arrays to store both an index number, name, and score for the player. How do i do that?
Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main (int argc, char** argv)
- {
- vector<double> doubleVector(10); //create a vector of 10 doubles
- double max;
- int i;
- for (i = 0; i < 10; i++) {
- doubleVector[i] = 0;
- }
- //Read the first score before the loop in order to initialize the max
- cout << "Enter score 1: ";
- cin >> doubleVector[0];
- max = doubleVector[0];
- for (i = 1; i<10; i++) {
- cout << "Enter score " << i + 1 << ": ";
- cin >> doubleVector[i];
- if (doubleVector[i] > max) {
- max = doubleVector[i];
- }
- }
- sort(doubleVector.begin(), doubleVector.end());
- for (i = 0; i < 10; i++) {
- cout << doubleVector[i] << " ";
- }
- cout << endl;
- return 0;
- }
thanks