Display mark in dicresing order (using map,set)

 avatar
user_6075971
plain_text
3 years ago
632 B
3
Indexable
#include <iostream>
#include <map>
#include <string>
#include <set>
using namespace std;
int main()
{
    map<int, multiset<string>> m;
    int n;
    cout << "ENTER THE CANDIDATE NO--->";
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string s;
        int x;
        cout << "ENTER THE NAME--->";
        cin >> s;
        cout << "ENTER THE NO--->";
        cin >> x;
        m[-1*x].insert({s});
    }
    for(auto v:m)
    {
       auto student_name=v.second;
       auto number=v.first;
       for(auto student:student_name) 
       {
           cout<<student<<" "<<-1*number<<endl;
       }
    }
    return 0;
}
Editor is loading...