Answers for "use of map in cpp"

C++
1

map in cpp

#include<bits/stdc++.h>
using namespace std;

int main()
{
  map<string,int>mapa;
  for(int i=0;i<10;i++){
    int x;
    string s;
    cin>>x>>s;
    mapa.insert({s,x});
    }
  for(auto [x,y]:mapa){
    cout<<x<<" "<<y<<'n';
  }
}
Posted by: Guest on June-15-2021
2

map in cpp

#include <map>

// empty map container 
map<int, int> gquiz1; 
  
// insert elements in random order 
gquiz1.insert(pair<int, int>(1, 40));
Posted by: Guest on October-01-2020

Browse Popular Code Answers by Language