计算机学院大学生程序设计竞赛(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 ...
随机推荐
- Redis中connect和pconnect的区别
首先先介绍下connect和pconnect的区别.connect:脚本结束之后连接就释放了. pconnect:脚本结束之后连接不释放,连接保持在php-fpm进程中.所以使用pconnect代替c ...
- ionic中 .col : 默认的定宽列
.col : 默认的定宽列 在ionic的栅格中,每一行的各列默认是等宽的,这使得实现一个图片 浏览界面非常简单.下图是instagram app的截图: instagram <!DOCTYPE ...
- VB webbrowser 控件的应用(跨域 内嵌网页元素的访问)
自动登录财付通,难点在于会出现验证码,并且验证码页是在iframe元素下的,出于各种安全考虑,webbrowser控件不提供这种访问机制!当然,第一想到的是将这个网页拿出来,可是输入完毕验证码后,点击 ...
- arcconf
arcconf create 1 logicaldrive max volume 0 31 noprompt 创建 Logical Drive, 这里 0 31 就是之前记录的 Channel, De ...
- 收缩sql server数据库日志
项目中,可能数据库(sql server数据库)日志太多,占了很多磁盘空间,可以通过收缩数据库日志,减少日志文件大小. 下面以Northwind数据库为例: 1.把数据库的恢复模式设置为“简单模式”: ...
- JNI调用问题(部分机型崩溃)
1.今日测试发现在部分手机上游戏会崩溃,通过logcat日志发现是jni调用问题(我猜测) 错误日志中有如下语句: trying to work around app JNI bugs, but di ...
- log4j2.xml配置及例子
1.使用log4j2需要下载包,如下: 2.配置文件可以有三种格式(文件名必须规范,否则系统无法找到配置文件): classpath下名为 log4j-test.json 或者log4j-test.j ...
- Echarts自适应浏览器大小
var myChart = echarts.init(document.getElementById('sitesChar')); var option = { title : { text: 'No ...
- 超棒的自定义超酷滚动条jQuery插件 - Perfect Scrollbar
可能大家厌倦了千篇一律的页面滚动条,如果你希望能够设计出与众不同的页面UI设计的话,Perfect ScrollBar可能就是你寻找的解决方案. 这个滚动条来自于一个个人项目,一个简单但是非常棒的滚动 ...
- 安卓常用 widget
验证码 public class SpinnerImg extends ImageView { /** * 完成选择后启动另外一个spinner */ private ItemListener ite ...