#include <iostream>
#include <string>
using namespace std;
int main()
{
string names[4] = {"Anna" , "Jenny", "George" , "Michael"};
int score[4];
for(int i = 0; i < 3; i++)
{
cout << names[i] << ": ";
cin >> score[i];
cin.ignore();
}
//sort by score
for ( int i = 0; i < 3; i++ )
{ score[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];
score[i] = score[j];
names[i] = names[j];
score[j] = temp;
names[j] = tmp_string;
}
}
}
for ( int k = 0; k < 3; k++ )
{
cout << endl;
cout <<names[k] << " = "<< score[k] << " ";
}
system("pause");
}
I've compiled it (with dev-c++), and it runs well.
I just need a few minor things.
1. I need it to sort descendingly, not ascendingly.
2. I need to know how to either print the output, or get the output sent to a word processor so it can be printed.
3. When the output is displayed, is there a way to clear the screen before-hand, so the input is cleared?
--thanks a million, guys.