1071. Speech Patterns (25)
来源:互联网 发布:软件集成测试 编辑:程序博客网 时间:2024/06/02 04:52
//1071. Speech Patterns (25)#include<string>#include<iostream>#include<map>#include<algorithm>using namespace std;int flag[256]={0};void init(){ for(int i='0'; i<='9'; i++) flag[i] = 1; for(int i='a'; i<='z'; i++) flag[i] = 1; for(int i='A'; i<='Z'; i++) flag[i] = 2; flag['_'] = 1;}int main(){ map<string,int> mp; int MAX=0,i=0; string word,ans,str; init(); getline(cin,str); while(i<str.length()) { while(i<str.length() && flag[str[i]] == 0) //非法字符 { i++; } while(i<str.length() && flag[str[i]] != 0) { if(flag[str[i]] == 2) str[i] = str[i] + ('a' - 'A'); word += str[i]; i++; } mp[word]++; word.clear(); } for(map<string,int>::iterator it=mp.begin(); it!=mp.end(); it++) { if(it->second>MAX) { MAX = it->second; ans = it->first; } } cout<<ans<<" "<<MAX<<endl; return 0;}
0 0
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- 1071. Speech Patterns (25)
- LeetCode 34.Search for a Range & 36.Valid Sudoku
- CCNU校赛2017
- 1069. The Black Hole of Numbers (20)
- ImportError: No module named _caffe
- jQuery事件绑定on()、bind()与delegate() 方法详解
- 1071. Speech Patterns (25)
- 55. Jump Game
- 谷歌浏览器九宫格的隐藏
- poj1003
- shell curl 数据中含有空格 如何提交
- 记——凡科业务运维工程师面试总结(5.10)
- PTA.重载下标运算符[ ]
- 通过dsp设备实现录音与放音编程实例
- SQLite教程(内置日期和时间函数)