ZOj 2104——Let the Balloon Rise
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                ZOj 2104——Let the Balloon Rise
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.                        
                                
                            
                            
                            老師在上課的時候講過這道題,不過當時做這道題時還是糾結(jié)了許久,那時stl不熟,老是想著用數(shù)組,去重很麻煩,學了STL后,用map就簡單多了。code :#include <iostream>
#include <string>
#include <map>
using namespace std;
int main() {
map < string, int >m;
string a, k;
int n, max;
while (cin >> n && n) {
m.clear();
while (n--) {
cin >> a;
m[a]++;
}
map < string, int >::iterator it;
max = 0;
for (it = m.begin(); it != m.end(); it++) {
if ((*it).second > max)?//遍歷尋找最大的氣球數(shù) {
max = (*it).second;
k = (*it).first;
}
}
cout << k << endl;
}
return 0;
}
                            
                        
                        
                        #include <string>
#include <map>
using namespace std;
int main() {
map < string, int >m;
string a, k;
int n, max;
while (cin >> n && n) {
m.clear();
while (n--) {
cin >> a;
m[a]++;
}
map < string, int >::iterator it;
max = 0;
for (it = m.begin(); it != m.end(); it++) {
if ((*it).second > max)?//遍歷尋找最大的氣球數(shù) {
max = (*it).second;
k = (*it).first;
}
}
cout << k << endl;
}
return 0;
}
總結(jié)
以上是生活随笔為你收集整理的ZOj 2104——Let the Balloon Rise的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: SDWebImage加载图片成功,但是程
- 下一篇: 上挑满,十字满,崩山满,小,大手满,死亡
