1071. Speech Patterns (25)
来源:互联网 发布:射手座男生 知乎 编辑:程序博客网 时间:2024/06/16 17:31
点击打开链接
2个点超时,sad。。。
注意
1.大写字母的ascii值比小写字母小32
2.字符数组的赋值用strcpy()函数
strcpy(字符数组1,字符数组2) --即将后面的赋值给前面的
#include <cstdio>#include <map>#include <string>#include <string.h>using namespace std;char c[1048576];char ans[1048576];char tmp[1048576];int times=0;map <string,int> mp;int main(){freopen("in.txt","r",stdin);gets(c);int cnt=0;for(int i=0;i<=strlen(c);){if(c[i]>='0'&&c[i]<='9' || c[i]>='a'&&c[i]<='z' || c[i]>='A' && c[i]<'Z'){if(c[i]>='A' && c[i]<'Z'){tmp[cnt++]=c[i++]+32;}else{tmp[cnt++]=c[i++];}}else if(c[i]==' ' || c[i]=='\0'){tmp[cnt]='\0';if(strlen(tmp)!=0){map <string,int>::iterator it=mp.find(tmp);if(it!=mp.end()){it->second++;}else{mp[tmp]=1;}}i++;cnt=0;if(mp[tmp]>times){times=mp[tmp];//strcoy(字符数组1,字符数组2)即将字符数组2的内容复制到字符数组1中strcpy(ans,tmp);}}else{i++;}}printf("%s %d\n",ans,times);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)
- WCF发布,怎么把电脑名改为IP地址
- UVA 10635
- Codeforces Round #288 (Div. 2)(A,B,C)
- DirectX学习笔记--3D基本数学知识整理
- Random rand =new Random(47);
- 1071. Speech Patterns (25)
- 解决php的It is not safe to rely on the system’s timezone settings的问题
- HDU--IMNU集训三:C语言合法标识符 多用库函数 以及 scanf的相关巧用
- 我的学习之旅(41)sched.c
- 基于MVC4+EasyUI的Web开发框架经验总结--实现Office文档的预览
- RDIFramework.NET ━ 9.3 用户管理 ━ Web部分
- PHP数据库连接失败--could not find driver 解决办法
- 英语年终总结
- 在centos下安装flashplayer