📄 pku2503.cpp
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct
{
char s_out[11];
char s_in[11];
} Word;
Word wo[100000], *pword, tos;
int cmp(const void *a, const void *b)
{
Word *aa = (Word *)a;
Word *bb = (Word *)b;
return strcmp(bb->s_in, aa->s_in);
}
int main()
{
int i = 0, l = 0;
char s[30];
while (gets(s), strcmp(s, ""))
{
i = 0;
while (s[i] != ' ')
{
i++;
}
s[i] = '\0';
i++;
strcpy(wo[l].s_out ,s);
strcpy(wo[l].s_in, s + i);
l++;
}
qsort(wo, l, sizeof(wo[0]), cmp);
while (scanf("%s", tos.s_in) != -1)
{
pword = (Word *)bsearch(&tos, wo, l, sizeof(wo[0]), cmp);
if (pword == NULL)
{
printf("eh\n");
}
else
{
printf("%s\n", pword->s_out);
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -