I am writing a program that uses unordered map. after some research prior to this, I know that to use unordered map, first we need to put header. but It didn't worked. thanks in advance for any tips. and oh ya this is the error message
#error This file requires compiler and library support for the \
^
umap.cpp: In function 'int main()':
umap.cpp:21:2: error: 'unordered_map' was not declared in this scope
unordered_map<string, int> siswa;
^
umap.cpp:21:22: error: expected primary-expression before ',' token
unordered_map<string, int> siswa;
^
umap.cpp:21:24: error: expected primary-expression before 'int'
unordered_map<string, int> siswa;
^
umap.cpp:24:2: error: 'siswa' was not declared in this scope
siswa["saleh"]=90;
^
AND here's the program
#include <iostream>
#include <unordered_map>
#include <bits/stdc++.h>
using namespace std;
void cari(string key){
if(siswa.find(key)==siswa.end())
cout<<siswa[key]<<endl;
else
cout<<"n/a"<<endl;
}
int main(){
unordered_map<string, int> siswa;
siswa["saleh"]=90;
siswa["mutiara"]=85;
siswa["icam"]=70;
int t;
cin>>t;
string key;
for(int i=0;i<t;i++){
getline(cin,key);
cari(key);
}
}
btw, sorry for my messy grammar :v
Aucun commentaire:
Enregistrer un commentaire