hdu_1004

 1 // hdu_1004

 2 // stl map

 3 // Dec.29 2014

 4 

 5 #include <cstdio>

 6 #include <map>

 7 #include <iostream>

 8 #include <string>

 9 

10 int T;

11 std::string str;

12 std::map<std::string, int> m;

13 

14 int main()

15 {

16     while(scanf("%d",&T) && T){

17         std::string max_str = "";

18         int max = -1;

19         while(T--){

20             std::cin>>str;

21             if (m[str] == 0)

22                 m[str] = 1;

23             else

24                 ++m[str];

25             if(max < m[str]){

26                 max = m[str];

27                 max_str = str;

28             }

29         }

30         std::cout<<max_str<<std::endl;

31     }

32 }

 

你可能感兴趣的:(HDU)