计算机学院大学生程序设计竞赛(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 ...
随机推荐
- Long-Polling, Websockets, SSE(Server-Sent Event), WebRTC 之间的区别
在下面的示例中,客户端指的是浏览器,服务器指的是网站服务器主机. 为了更好的理解这些知识点,你应该简单了解典型的http网站是如何工作的. 普通的http: 客户端从服务器端请求网页 服务器作出相应的 ...
- VG、LV、rezise2fs、lvresize、fuer使用说明
南沙节点改变LV大小,参考鸟哥第 570页 1.# resize2fs /dev/mapper/vg_niotsvr3-lv_home 150G resize2fs 1.41.12 (17-May-2 ...
- 硬盘安装win8系统方法汇总
从硬盘安装 (推荐)硬盘安装方法一 使用Nt6 hdd installer进行安装,此方法适合XP,vista, Windows 7等系统. 下载Nt6 hdd installer(Win8硬盘安装工 ...
- qmake pro工程设置
----我的生活,我的点点滴滴!! #以下是在terminal里面编译,想编译哪个就修改pro文件 #================================================= ...
- shell查看进程
用shell脚本监控进程是否存在 不存在则启动的实例,先上代码干货: #!/bin/shps -fe|grep processString |grep -v grepif [ $? -ne 0 ]th ...
- JSON中的特殊字符
使用JSON从后台向前台传输数据的时候,当数据本身含有一些特殊字符,会导致JSON数据的解析出错.这个时候,就需要将JSON中的特殊字符过滤掉. 用下面的方法对即将向前台输出的json字符串进行处理, ...
- 要想提高PHP的编程效率,你必须遵守的原则
用单引号代替双引号来包含字符串,这样做会更快一些.因为PHP会在双引号包围的字符串中搜寻变量,单引号则不会,注意:只有echo能这么做,它是一种可以把多个字符串当作参数的“函数”(译注:PHP手册中说 ...
- java设计模式案例详解:工厂模式
1.简单工厂模式 在不考虑扩展的情况下还是很好用的,其实我们写代码也很经常用到,其主要理解在于传入不同参数则构建不同对象,只有一个工厂,如需添加产品涉及到扩展需要修改比较多的东西,不符合开闭原则,如下 ...
- php杂乱
// // if ( $_GET['action'] == 'search' ) {// $_clean = array();// $_clean['stype ...
- shell 各种循环判断
shell支持的循环有 Shell if else Shell case esac Shell for循环 Shell while循环 Shell until循环