Okay, so i've gotten some help, however i'm still missing some things.
In the code below,
I have a Bowler's name, and their score.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string names[3] = {"John","Anne","Mary"};
int score[3] = {5,1,2};
//i.e
//John's score = 5
//Anne's score = 1
//Mary's score = 2
//sort by score
for ( int i = 0; i < 3; i++ )
{
for ( int j = 0; j < 3; j++ )
{
if( score[i] < score[j] )
{
string tmp_string;
int temp;
temp = score[i];
tmp_string = names[i]; //now swap the names array
score[i] = score[j];
names[i] = names[j]; //now swap the names array
score[j] = temp;
names[j] = tmp_string; //now swap the names array
}
}
}
//show them sorted
cout << "Sorting by score in ascending order\n";
for ( int k = 0; k < 3; k++ )
{
cout << "name:" << names[k] << " score:" << score[k] <<endl;
}
return 0;
}
However, I want to change it where the "int score" is, so that the user can input the scores manually. I want the program to have a
cout << "Anna's Bowling Score: ";
code.
Can somebody help me out?