计算机学院大学生程序设计竞赛(2015’12) 1008 Study Words
#include<cstdio>
#include<cstring>
#include<map>
#include<string>
#include<algorithm>
using namespace std; int T;
char s[+];
char r[+];
map<string,int>m;
struct dan
{
char s[+];
int num;
}d[+];
int sum;
int tot; bool cmp(const dan&a,const dan&b)
{
if(a.num==b.num) return strcmp(a.s,b.s)<;
return a.num>b.num;
} //转小写
void F()
{
for(int i=;s[i];i++)
if(s[i]>='A'&&s[i]<='Z')
s[i]=s[i]-'A'+'a';
} void work()
{
int len=strlen(s);
tot=;
for(int i=;i<=len;i++)
{
if(s[i]>='a'&&s[i]<='z') r[tot++]=s[i];
else
{
r[tot]='\0';
if(strlen(r)>) m[r]=-;
tot=;
}
}
} void work2()
{
int len=strlen(s);
tot=;
for(int i=;i<=len;i++)
{
if(s[i]>='a'&&s[i]<='z') r[tot++]=s[i];
else
{
r[tot]='\0';
if(strlen(r)>)
{
if(m[r]!=-)
{
if(m[r]==) strcpy(d[sum++].s,r);
m[r]++;
}
}
tot=;
}
}
} int main()
{
scanf("%d",&T);
while(T--)
{
int flag=;
m.clear();
sum=;
while()
{
scanf("%s",s);
if(strcmp(s,"<oldwords>")==) {flag=;continue;}
if(strcmp(s,"</oldwords>")==) {flag=;continue;}
if(strcmp(s,"<article>")==) {flag=;continue;}
if(strcmp(s,"</article>")==) break;
if(flag==)
{
F();
work();
}
if(flag==)
{
F();
work2();
}
}
for(int i=;i<sum;i++) d[i].num=m[d[i].s];
sort(d,d+sum,cmp); for(int i=;i<min(,sum);i++) printf("%s\n",d[i].s);
printf("\n");
}
return ;
}
计算机学院大学生程序设计竞赛(2015’12) 1008 Study Words的更多相关文章
- hdu 计算机学院大学生程序设计竞赛(2015’11)
搬砖 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submissi ...
- 计算机学院大学生程序设计竞赛(2015’11)1005 ACM组队安排
1005 ACM组队安排 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Pro ...
- 计算机学院大学生程序设计竞赛(2015’12)Study Words
Study Words Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- 计算机学院大学生程序设计竞赛(2015’12)Polygon
Polygon Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
- 计算机学院大学生程序设计竞赛(2015’12)The Country List
The Country List Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 计算机学院大学生程序设计竞赛(2015’12) 1009 The Magic Tower
#include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using ...
- 计算机学院大学生程序设计竞赛(2015’12) 1006 01 Matrix
#include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> ...
- 计算机学院大学生程序设计竞赛(2015’12) 1003 The collector’s puzzle
#include<cstdio> #include<algorithm> using namespace std; using namespace std; +; int a[ ...
- 计算机学院大学生程序设计竞赛(2015’12) 1004 Happy Value
#include<cstdio> #include<cstring> #include<cmath> #include<vector> #include ...
随机推荐
- tar.gz tar.bz2 解压
从网络上下载到的源码包, 最常见的是 .tar.gz 包, 还有一部分是 .tar.bz2包 要解压很简单 : .tar.gz 格式解压为 tar -zxvf ...
- passwd总结
1.当前用户是root root用户修改密码 ,直接 passwd[不要输入当前用户密码] 如果修改其他用户密码,需要 passwd 用户名 如: passwd sc 短短的密码,如123也能通过,因 ...
- unity3d自带帮助文档的打开方法
1废话不提,直接上图: 2.在弹出来的浏览器窗口中点击: 3.在点击后的网页中即可以搜索了,在断网的情况下,作为资料查询还是蛮不错的.
- 严格递增类的dp Codeforces Round #371 (Div. 1) C dp
http://codeforces.com/contest/713 题目大意:给你一个长度为n的数组,每次有+1和-1操作,在该操作下把该数组变成严格递增所需要的最小修改值是多少 思路:遇到这类题型, ...
- Oracle record 解锁
Oracle修改表中记录时出现record is locked by another user的弹出框问题 是因为在操作表中数据时没有commit,导致表被锁. 执行下面两行语句: (1)查看被锁表的 ...
- beagleboneblack HDMI不能显示
beagleboneblack 接上HDMI到电视上,没有显示画面 看了资料之后才知道 http://elinux.org/Beagleboard:BeagleBoneBlack_HDMI#Conn ...
- idea编译报错:未结束的字符串文字;非法的表达式;未结束的字符串字面值
在idea的Settings中,找到File Encodings,将IDE Encoding 改为UTF-8 要多试几次,清除缓存什么的,具体原因不知道,不过经常第一次修改不能成功.
- Spring Boot 系列教程13-注解定时任务
注解 @Scheduled(cron = "0/5 * * * * ?") 相当于原来的xml版本的如下配置 <task:scheduled ref="schedu ...
- php 代码编写的格式
1.代码标记 php程序可以使用<?php .... ?> 或 <? ..... ?> 来界定php代码,在html页面中嵌入纯变量是,可以使用<?= $variabl ...
- 问题:FF中把UL下的LI设为左浮动UL的背景色就没有了?
因为容器的子元素设置浮动后, 内容移出了文档流! 解决办法: 1.给个overflow:hidden;作为闭合浮动元素2.设定UL 一个固定的高度 下面是一些与之相关的解决办法,参考文章<那些 ...