-
Notifications
You must be signed in to change notification settings - Fork 0
/
17_9.cpp
37 lines (31 loc) · 749 Bytes
/
17_9.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// 17_9.cpp
//
//
// Created by Pengyan Qin on 7/21/15.
//
//
#include <iostream>
#include <unordered_map>
#include <string>
#include <algorithm>
using namespace std;
unordered_map<string, int> map_strings(string A[], int n){
unordered_map<string, int> mymap;
for(int i = 0; i < n; ++i){
if(A[i] != ""){
string word = A[i];
transform(word.begin(), word.end(), word.begin(), ::tolower);
mymap[word]++;
}
}
return mymap;
}
int main(){
string A[] = {"Aa", "bb", "", "cc", "aa", "aa", "bb"};
int n = 7;
unordered_map<string ,int> mymap = map_strings(A, n);
string aa = "aA";
transform(aa.begin(), aa.end(), aa.begin(), ::tolower);
cout << mymap[aa] << endl;
}