91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3KB
    文件類型: .rar
    金幣: 2
    下載: 1 次
    發布日期: 2021-06-17
  • 語言: C/C++
  • 標簽: 源碼??工具??

資源簡介

NULL 博文鏈接:https://touch-2011.iteye.com/blog/1038921

資源截圖

代碼片段和文件信息

/******************************************************************************/
//??作者:劉海房
//??版本:第二版
//??時間:2011-04-07
/******************************************************************************/
/*
題目:
某英漢詞典包含N個記錄,每個記錄有兩個字段:一個是英文單詞,另一個是中文解釋。
各個記錄按英文單詞的詞典順序排列,各英文單詞并不重復。輸入英文單詞和中文解釋
(用空格隔開),若此單詞已存在,則把這個單詞的中文解釋覆蓋掉,若不存在,則把
此單詞加入詞典。(輸入的大寫字母全部轉換成小寫,詞典中沒有大寫字母)。單詞在文
本文件中的存儲形式:(單詞和中文有空格隔開)dictionary.txt
about?關于
boy?男?
cat?貓
welcome?歡迎
*/
//注意事項:
//單詞最多只能有一千個
//輸入的時候英文單詞和中文解釋要用空格隔開
/*******************************************************************************/

#include
#include
#include

//函數聲明
int?Search(char?words[][30]char?word[30]int?lowint?high);//在字典中查找單詞
void?Insert(char?words[][30]char?word[30]int?indexint?length);//把單詞插入到字典中
void?Close_File(FILE?*fp);//關閉文件
FILE?*?Open_File_W(FILE?*fp);//以wt的方式打開文件
FILE?*?Open_File_R(FILE?*fp);//以rt的方式打開文件

//主函數
void?main()
{
//變量聲明
int?j=0;
int?i=0;
FILE?*fp;
int?index=0;
char?engwords[1000][30];?//存放詞典中單詞的英文部分
char?words[1000][30];????//words存放詞典
char?engword[30];????????//engword存放輸入的單詞的英文部分
char?word[30];???????????//word存放輸入的單詞

//初始化engwords和words
for(i=0;i<1000;i++){
words[i][0]=‘\0‘;
engwords[i][0]=‘\0‘;
}

//打開文件并把文件中的單詞都讀入到words二維數組里面
fp=Open_File_R(fp);
i=0;
while(!feof(fp)){
????????fgets(words[i++]30fp);
}
Close_File(fp);

//取出詞典中單詞的英文部分
????for(i=0;words[i][0]!=‘\0‘;i++){
for(j=0;words[i][j]!=‘?‘;j++)
????????????engwords[i][j]=words[i][j];
engwords[i][j]=‘\0‘;
}

//讀取輸入的單詞并取出輸入單詞的英文部分
printf(“please?input?your?wordseparation?the?english?and?chinese?with?empty?bay:\n“);
gets(word);
j=0;
????while(word[j]!=‘\0‘)
{
j++;
}
word[j]=‘\n‘;//在word后面加上換行符號因為詞典中讀出來的單詞都有換行符
word[j+1]=‘\0‘;
j=0;
while(word[j]!=‘?‘){
engword[j]=word[j];
j++;
}
engword[j]=‘\0‘;

//調用Search函數,在詞典中查找是否存在輸入的單詞
strlwr(engword);//將大寫字母轉換成小寫字母
index=Search(engwordsengword0i-1);
if(strcmp(engwordengwords[index])==0)//如果這個單詞存在把這個單詞覆蓋掉
{
????printf(“the?word?is?exit!\n“);
strcpy(words[index]word);
}
else//此單詞不存在,插入到詞典中
{
printf(“the?word?is?not?exit!?and?alreadly?insert?into?the?dictionary!\n“);
Insert(wordswordindexi);
}

????//更新文件dictionary.txt
????fp=Open_File_W(fp);
????for(i=0;words[i][0]!=‘\0‘;i++)
????fputs(words[i]fp);
Close_File(fp);
}

//用二分查找法查找單詞傳入的參數是:詞典,要查找的單詞,詞典首、尾。若找到則返回這個單詞的下標,找不到,則返回這個單詞應該插入的位置
int?Search(char?words[][30]char?word[30]int?lowint?high)
{
int?mid;
if(low>high)
return?low;
mid=(low+high)/2;
if(strcmp(wordwords[mid])==0)
???? return?mid;
if(strcmp(wordwords[mid])>0)
low=mid+1;
if(strcmp(wordwords[mid])<0)
high=mid-1;
Search(wordswordlowhigh);
}

//把單詞插入到存放詞典的數組中
void?Insert(char?words[][30]char?word[30]int?indexint?length)
{
int?i;
????for(i=length-1;i>=index;i--)
????strcpy(words[i+1]words[i]);
strcpy(words[index]word);
}

//以r

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????4155??2011-04-08?20:31??源代碼\1.c

?????文件????????178??2011-04-06?20:49??源代碼\document\a.cpp

?????文件????????175??2011-04-07?21:36??源代碼\document\a1.cpp

?????文件????????142??2011-04-08?20:23??源代碼\document\account.txt

?????文件?????????92??2011-04-08?20:32??源代碼\document\dictionary.txt

?????文件????????151??2011-04-10?21:55??源代碼\document\file4.txt

?????文件????????162??2011-04-10?22:21??源代碼\document\file4_answer.txt

?????目錄??????????0??2011-05-10?13:44??源代碼\document

?????目錄??????????0??2011-05-10?13:44??源代碼

-----------?---------??----------?-----??----

?????????????????5055????????????????????9


評論

共有 條評論