?? 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 + -