Nested map using vector pair (input subject no)

 avatar
user_6075971
plain_text
2 years ago
991 B
0
Indexable
Never
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main()
{
    map<pair<string, string>, vector<int>> m;
    int n;
    cout << " ENTER THE INSERT SIZE--->";
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string f, l;
        int z;
        cout << "ENTER THE FIRST NAME--->";
        cin >> f;
        cout << "ENTER THE SECOND NAME--->";
        cin >> l;
        cout << "ENTER THE SUBJECT SIZE(IN NO)--->";
        cin >> z;
        for (int j = 0; j < z; j++)
        {
            int a;
            cout << "ENTER THE SUBJECT NO("<<j<<")--->";
            cin >> a;
            m[{f, l}].push_back(a);
        }
    }
        for (auto value : m)
        {
            auto first = value.first;
        auto list = value.second;
        cout << first.first <<" " << first.second << endl;
        cout << list.size() << endl;
        for (auto r : list)
        {
            cout << r<<"  ";
        }
        cout << endl;
    }
    return 0;