计算机学院大学生程序设计竞赛(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 ...
随机推荐
- table新增空白行到首行
var str=""; str+="<tr bordercolor='#DEDEDE' bgcolor='#ffffff'>"; str+=&quo ...
- 设计模式C#(一)
引言 模式(pattern) 一种方案,利用这种方案 完成某种工作. 一种途径,通过这种途径达到某个目的. 一种技术,利用他有效的完成某项工作. 某些领域的从业人员会产生该领域的习惯用语(行话),用语 ...
- runtime——消息机制
本文授权转载,作者:Sindri的小巢(简书) 从异常说起 我们都知道,在iOS中存在这么一个通用类类型id,它可以用来表示任何对象的类型 —— 这意味着我们使用id类型的对象调用任何一个方法,编译器 ...
- apicloud教程1 (转载)
非常感谢APICloud官方给我版主职位,每天都看到很多朋友提出很多问题,我就借此机会写了一系列的教程,帮助大家从小白到高手之路.系列名称:<APICloud之小白图解教程系列>,会不定时 ...
- C++调用com控件方法
转载自:http://blog.csdn.net/haijun286972766/article/details/6273414 最近要求做一个C++调用com组件的DEMO.由于自己对C++并无研究 ...
- 函数求值一<找规律>
函数求值 题意: 定义函数g(n)为n最大的奇数因子.求f(n)=g(1)+g(2)+g(3)+-+g(n).1<=n<=10^8; 思路: 首先明白暴力没法过.问题是如何求解,二分.知道 ...
- Android NDK and OpenCV Development With Android Studio
Android NDK and OpenCV Development With Android Studio Hujiawei 172 2014年10月22日 发布 推荐 0 推荐 收藏 4 收藏,5 ...
- java数据结构之链表的实现
这个链表的内部是使用双向链表来表示的,但是并未在主函数中进行使用 /** * 链表 * 2016/4/26 **/ class LinkList{ Node head = new Node(); No ...
- css 7.30
1.外提到内联元素,我们会想到有个display的属性是display:inline;这个属性能够修复著名的IE双倍浮动边界(float时margin)问题 2.一般来说,可以为所有块级元素应用 te ...
- java数组的引用
数组属于应用型变量,因此两个相投类型的数组如果具有相同的引用,它们就有完全相同的元素 如: int a[]={1,2,3},b[]={4,5} 如果a=b;则a[]={4,5} public clas ...