qsort/bsearch的应用
问题描述:
Description
You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.
Input
Input consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.
Output
Output is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".
Sample Input
dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay
atcay
ittenkay
oopslay
Sample Output
cat
eh
loops
大意描述:
模拟一本双语辞典的功能,用户输入一种语言,通过字典翻译成另外一种语言
参考资料:
http://www.slyar.com/blog/poj-2503-c.html
问题解决:
注:
程序,主要是使用了排序和二分查找,进行字典排序和字典查找
源文件:
qsort/bsearch的应用的更多相关文章
- 在stm32开发可以调用c标准库的排序和查找 qsort bsearch
在嵌入式开发中,可以使用c标准库自带的库函数,而不用自己去早轮子,qsort 和bsearch就是其中的两个比较好用的 二分法查找,前提是已经排序好的数据.下面的代码, 如果数据为排序,则要进行排序后 ...
- 模板:qsort+bsearch应用
(1)qsort: 功 能: 使用快速排序例程进行排序 头文件:stdlib.h 用 法: void qsort(void *base,int nelem,int width,int (*fcmp)( ...
- C语言标准库 qsort bsearch 源码实现
C语言是简洁的强大的,当然也有很多坑.C语言也是有点业界良心的,至少它实现了2个最最常用的算法:快速排序和二分查找. 我们知道,对于C语言标准库 qsort和 bsearch: a. 它是“泛型”的, ...
- qsort()和bsearch()
qsort void qsort (void* base, size_t num, size_t size, int (*compar)(const void*,const void*)); Sort ...
- 侯捷STL学习(一)
开始跟着<STL源码剖析>的作者侯捷真人视频,学习STL,了解STL背后的真实故事! 视频链接:侯捷STL 还有很大其他视频需要的留言 第一节:STL版本和重要资源 STL和标准库的区别 ...
- 07--STL序列容器(Array)
一:Array了解 array<T,N> 模板定义了一种相当于标准数组的容器类型.它是一个有 N 个 T 类型元素的固定序列.除了需要指定元素的类型和个数之外,它和常规数组没有太大的差别. ...
- 02--STL序列容器(Vector)
一:vector容器简介 图片和顺序栈相似,但是vector数组是动态数组,支持随机存取--->但是在尾部添加或者溢出元素非常快速,中间插入删除费时 vector是将元素置于一个动态数组中加以管 ...
- 转 What is Redis and what do I use it for?
原文: http://stackoverflow.com/questions/7888880/what-is-redis-and-what-do-i-use-it-for Redis = Remote ...
- cstdlib和stdlib.h区别
一.区别 #include<stdlib.h> :.h是C的习惯 #include<cstdlib> : c开头是C++的习惯 二.stdlib.h是C语言库头文件之一,包含了 ...
随机推荐
- 读书笔记-常用设计模式之MVC
1.MVC(Model-View-Controller,模型-视图-控制器)模式是相当古老的设计模式之一,它最早出现在SmallTalk语言中.MVC模式是一种复合设计模式,由“观察者”(Observ ...
- 20141109--SQL 练习题-1
create database xinxiku go use xinxiku go create table Student ( Sno ) primary key, Sname ) not null ...
- php_1
简介:(“PHP: Hypertext Preprocessor”,超文本预处理器的字母缩写)是一种被广泛应用的开放源代码的多用途脚本语言,它可嵌入到 HTML中,尤其适合 web 开发,语言的风格有 ...
- CTG
服务端:一.修改IP地址AIX上CICS REGION的目录/var/cics_regions/your_region_name/database/LD二.修改文件LD.stanza中的IP地址三. ...
- js中的继承1--类继承
继承:function Animal(name){ this.name = name; this.showName = function(){ alert(this.name); } } functi ...
- mfc110ud.dll not found
mfc110ud.dll not found while debugging vs2012 MFC application. Possible Solutions: 1) >>>&g ...
- 实验三——SDRAM
一.运行环境 开发板:jz2440 系统: ubuntu12.04 编译器:arm-linux-gcc 二.特殊寄存器 sdram的操作无需按照时序图来设置,只要设置好相关的13个寄存器,arm处理 ...
- Zedboard VmodCAM PIN Constraint
自己画了一块FMC-VHDCI四层板,外接VmodCAM,接口定义如下 #CAMA PIN CONSTRACT NET "CAMA_D_I[7]" LOC = T17 | IOST ...
- VisualVM 监控
一:服务器端: 找到 jstatd 所在目录 find / -name jstatd 在此目录下添加 jstatd.all.policy 文件 cat /usr/java/jdk1.7.0_51/bi ...
- 2013-07-26 IT 要闻速记快想
### ========================= ###传Google正在内测供用户买卖技能的电商平台Helpout,最早于下月上线该服务将依托Google强大的云服务和搜索能力,以实时视频 ...