📄 2781055_ac_78ms_564k.cpp
字号:
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int num;
struct node
{
char str[50];
}word[10001];
void check(char tmp[])
{
int i;
for (i = 0; tmp[i]!='\0'; i++)
if(tmp[i]>='A'&&tmp[i]<='Z')
tmp[i] += ' ';
}
bool cmp(node a,node b)
{
return strcmp(a.str,b.str)<0;
}
int main()
{
int i, j, n, ans, t;
char tmp[200];
char str[50];
while(scanf("%d",&n)==1)
{
num = 0;
while(1)
{
scanf("%s",tmp);
check(tmp);
if(strcmp(tmp,"endoftext")==0)
break;
for(j = 0; tmp[j]!='\0'; j++)
{
if(tmp[j]>='a'&&tmp[j]<='z')
{
i = 0;
while(tmp[j]!='\0'&&tmp[j]>='a'&&tmp[j]<='z')
str[i++] = tmp[j++];
str[i] = '\0';
strcpy(word[num++].str,str);
j--;
}
}
}
sort(word,word+num,cmp);
ans = 0;
for(i = 0; i < num; i++)
{
j = i;
t = 0;
while(j<num&&strcmp(word[j].str,word[i].str)==0)
t++,j++;
if(t==n)
{
puts(word[i].str);
ans++;
}
i = j-1;
}
if(ans==0)
puts("There is no such word.");
printf("\n");
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -