/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include<utility> // for pair
#include<algorithm> // for sort
#include<string>
#include<iostream>
int main() {
const int MAX_NAMES = 3; // example
std::pair<int, std::string> scoreboard[MAX_NAMES] = {
{22, "Anna"}, {11, "Bo"}, {33, "Clare"} // using c++11 inline initialization
};
std::sort(scoreboard, scoreboard + MAX_NAMES); // sorts in place using operator<
for (int i = 0; i < MAX_NAMES; ++i) {
std::cout << i << ") " << scoreboard[i].second << " has " << scoreboard[i].first << " points" << std::endl;
}
return 0;
}