Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aepod/0f3088a930e28aeb6036255bfb747918 to your computer and use it in GitHub Desktop.
Save aepod/0f3088a930e28aeb6036255bfb747918 to your computer and use it in GitHub Desktop.
8.1 cities
#include <iostream>
#include <string>
#include <map>
using namespace std;
string province(string);
typedef map<string,string> , ProvinceList;
int main(){
string city, abbrev, prov;
cout<<"Enter city: ";
getline(cin,city);
cout<<"Enter province abbreviation: ";
cin>>abbrev;
prov = province(abbrev);
cout<<city+prov;
return (0);
}
string province (string abbrev){
typedef map<string,string> , ProvinceListMap;
ProvinceListMap ProvinceList;
ProvinceList["BC"] = "British Columbia";
return ProvinceList.find(abbrev)->second;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment