词典
来源:互联网 发布:mac迅雷下载界面没了 编辑:程序博客网 时间:2024/06/10 09:15
/**程序的版权和版本声明部分:*Copyright(c)2013,烟台大学计算机学院学生*All rights reserved.*文件名称:*作者:曹昕卓*完成日期:2013年 12月6 日*版本号:v1.0*对任务及求解方法的描述部分:*输入描述: 一个英语单词*问题描述:输入一个单词,输出对应的中文意思*程序输出:中文意思*问题分析:*算法设计:*/#include<iostream>#include<string>#include<iostream>#include<string>#include<iostream>#include<string>#include<cstdio>#include<fstream>#include<cstdlib>using namespace std;int main(){ int i=0; string english[10000],word,chinese[10000]; int high,low,mid; ifstream infile("D:\\english.txt",ios::in); if(!infile) { cerr<<"open error!"<<endl; exit(1); } while(!infile.eof()) {infile>>english[i]>>chinese[i];i++;}infile.close();while(cin>>word){if(word=="0000"){break;}else{high=i;low=0;mid=(high+low)/2;while(low<high&&english[mid]!=word){if(english[mid]<word){low=mid+1;}if(english[mid]>word){high=mid-1;}mid=(high+low)/2;}if(english[mid]!=word){cout<<"查无此词!"<<endl;}else{cout<<word<<"的意思是:"<<chinese[mid]<<endl;}}}return 0;}
成果展示:
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典--词典树,检索
- 程序员词典
- 低功耗无线通信模块
- VPD
- JS querySelector
- 多行注释技巧
- iOS开发者申请发布证书-图文详解
- 词典
- 一个例子帮你搞懂C#语言高级特性系列(02) --- 委托、事件和Lambda表达式
- thrift使用过程中的问题
- 数组的排列选择法
- Tomcat:IOException while loading persisted sessions: java.io.EOFException解决手记
- 动态SQL
- 在 Web 项目中应用 Apache Shiro
- 读朱兆祺攻破C语言之六---数组、指针
- 那天有个小孩跟我说LINQ(一)