第14周项目4 英汉词典
来源:互联网 发布:网络歌曲么么哒 编辑:程序博客网 时间:2024/05/17 07:44
/* *Copyright (c)2014,烟台大学计算机与控制工程学院 *All rights reserved. *文件名称:gcd.cpp *作 者:惠睿 *完成日期:2014年11月30日 *版 本 号:v1.0 * *问题描述:输入英文词汇,输出汉语意思。*程序输出:输出成绩单。*/#include <fstream>#include<iostream>#include<cstdlib>#include<string>using namespace std;string e[8000],c[8000];int wordsNum=0;int BinSeareh(int low, int high, string k);int main( ){ string key;ifstream infile("dictionary.txt",ios::in);if(!infile){cerr<<"open error!"<<endl;exit(1);}while (infile>>e[wordsNum]>>c[wordsNum]){++wordsNum;}infile.close();do{cout<<"请输入要查的词(0000结束):";cin>>key;if (key=="0000")break;else{int low=0,high=wordsNum-1;int index=BinSeareh(low, high, key);if (index == -1)cout<<"查无此词!"<<endl<<endl;elsecout<<key<<"的中文意思是:"<<c[index]<<endl<<endl;}}while(1);cout<<"欢迎再次使用!"<<endl<<endl;return 0;}int BinSeareh(int low, int high, string k){int mid;while(low<=high){mid=(low + high) / 2;if(e[mid]==k){return mid;}if(e[mid]>k)high=mid-1;elselow=mid+1;}return -1;}
运行结果:
学习心得:好麻烦的程序!
0 0
- 第14周项目4 英汉词典
- 英汉词典
- python项目之 英汉词典 带GUI tkinter
- Centos6.4安装星际译王英汉词典
- 第14周项目4-电子词典
- 第14周项目4-电子词典
- 第14周项目 4电子词典
- 第14周项目4-电子词典
- 第14周项目4-电子词典
- 第14周 项目4-电子词典
- 第14周项目4-电子词典
- 第14周项目4电子词典
- 第14周项目4电子词典
- 第14周项目4-电子词典
- 第14周 项目4 电子词典
- 第14周项目4-电子词典
- 第14周项目4-电子词典
- 第14周 项目一
- css 之margin collapsing(外边距叠加)
- OpenCV读取多幅图片,读取系列图片,读取文件夹中指定图像类型的系列图片
- Routing in Zend Framework 2, skip 'index' action in url but get id
- 【UINX】什么是守护进程
- 第十四周项目3 (3)
- 第14周项目4 英汉词典
- python 注释
- poj解题报告——1008
- hdu2795——Billboard
- fstream 中 eofbit 的控制
- iptables使用实例
- C++标准库---set&multiset
- WPF中多线程技术日记(一)
- 多科成绩单