1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 简单的电子词典 因手机问题未图

简单的电子词典 因手机问题未图

时间:2022-03-08 07:18:43

相关推荐

简单的电子词典    因手机问题未图

01./* 02.*Copyright (c) ,烟台大学计算机学院 03.*All rights reserved. 04.*文件名称: test.cpp 05.*作 者:李晓凡 06.*完成日期:11月28日 07.*版本号:v1.0 08.* 09.*问题描述: 做一个简单的电子词典10.*输入描述: 所需查找单词11.*程序输出: 汉语意思12.*/#include<iostream>#include<string>#include<fstream>#include<cstdlib>using namespace std;int found(int a,string word);string e[8000];string c[8000];int main(){int i,n,index;string eword;ifstream infile ("dictionary.txt",ios::in);if (!infile){cerr<<"open error!"<<endl;exit(1);}for (i=0;i<8000;i++){infile>>e[i];infile>>c[i];}infile.close();n=i;while (eword!="0000"){cout<<"请输入要查寻的英语单词 0000结束"<<endl;cin>>eword;if (eword=="0000"){cout<<"谢谢使用";break;}else {index=found(n,eword);if (index==0)cout<<"未找到您要查询的单词"<<endl;else cout<<e[index]<<"的汉语意思是 :"<<c[index]<<endl;}}return 0;}int found(int high,string word){int low=0,mid;while (low<=high){mid=(low+high)/2;if (word==e[mid]){return mid;break;}else {if (word>e[mid])low=mid+1;elsehigh=mid-1;}}return 0;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。