⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 string dictionary order.txt

📁 1.表达式求值;2.二分匹配模板;3.最大流;4.点到线段的距离;5.字符串字典顺序
💻 TXT
字号:
#include <stdio.h>
#include <stdlib.h>

struct dic {
   char eng[12], forn[12];
} d[100000];

int cnt = 0 , i,j,k;
char buf[10000];

compar(struct dic *a, struct dic *b) {
   return strcmp(a->forn, b->forn);
}

main(){
   while (gets(buf) && buf[0]) 	//读一行,gets
   {
      sscanf(buf,"%s %s",d[ cnt ].eng,d[ cnt ].forn);			//将buf分别读入到两个字符串中,空格分开!!!  好啊!!
      cnt++;
   }
   qsort(d, cnt ,sizeof(struct dic),(int (*) (const void *, const void *)) compar);		//字符串按字典顺序排序!!
   while ( gets(buf) ) 			//读到文件结束!!
   {
      struct dic b, *p;
      strcpy( b.forn, buf);
      p = bsearch(&b,d,cnt ,sizeof(struct dic),(int (*) (const void *, const void *)) compar);		//二分搜索!!!!
      if (p != NULL) printf("%s\n",p->eng);		
      else printf("eh\n");
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -