當前位置:首頁 » 編程語言 » 雙字典c語言
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

雙字典c語言

發布時間: 2022-07-22 20:59:36

『壹』 運用c語言編寫一個英漢字典~ 謝謝啦~先

原型:
int WINAPI icePub_dictionaryCodeTransfer2(char *strDictionaryFilename,char *strSrc,char *strCode,char *strFenge)
輸入:strDictionaryFilename 字典文件名
strSrc 待處理單詞
strFenge 字典里單詞和code之間的分隔符字元串
輸出:strCode strSrc對應信息
返回碼:

原型:
int WINAPI icePub_dictionaryAddRecord(char *strDictionaryFilename,char *strSrc,char *strCode,char *strFenge)
輸入:strDictionaryFilename 字典文件名
strSrc 待添加單詞(如果存在則替換)
strCode strSrc對應信息
strFenge 字典里單詞和code之間的分隔符字元串
輸出:
返回碼:

原型:
int WINAPI icePub_dictionaryDelRecord(char *strDictionaryFilename,char *strSrc,char *strFenge)
輸入:strDictionaryFilename 字典文件名
strSrc 待刪除單詞
strFenge 字典里單詞和code之間的分隔符字元串
輸出:
返回碼:

網路一個《icepubdll揭秘》有詳細說明

『貳』 用c語言編寫電子英漢詞典。

為了保證效率,建議使用哈希結構或者2岔樹結構。
只需要提供插入刪除和檢索功能就可以了。
另外為字典的每個單元定義一個結構。
可以包含左右指針,自己的名詞,及解釋,還可以有其他東西。
然後實現樹型結構的刪除和檢索功能就可以了。這個在數據結構的書上有吧。
然後寫一個主函數就可以了。

『叄』 用c語言編寫英語字典

}
cout << endl;
int Scale = 5;
int dbn = 2;
cw.InitDecInfo2D(height, width, Scale, dbn);
double *dstcoef = new double[cw.m_msgCL2D.allSize];
cw.WaveDec2(s,dstcoef);

for (int i = 0; i < cw.m_msgCL2D.allSize; i++)
{
cout << dstcoef[i] << " ";
if ((i + 1) % 10 == 0)
cout << endl;
}
double *dst = new double[48];
for (int i = 0; i < 48; i++)
dst[i] = 0.0;
cw.WaveRec2(dstcoef, dst);
cout << endl; cout << endl;
for (int i = 0; i < 48; i++)
{
cout << dst[i] << " ";
if ((i + 1) % 8 == 0)
cout << endl;
}

『肆』 C語言中,雙位元組操作問題,

在C語言中除了字元類型(char)是固定的1位元組,其它類弄基本要看你的系統而定,
有些系統(整型)int是2位元組,而有些是4位元組.

如是兩位元組就可以

int x;
x=x/500;

『伍』 C語言!!!!字典!!!!!

#include <iostream>
#include <map>
#include <cstdio>
#include <string>
using namespace std ;

map<string,string> m ;

int main( )
{
char s[42] , *p , *q ;
int i ;

while( gets( s ) && s[0] != '\0' )
{
p = strtok( s , " " ) ;
q = strtok( NULL , " " ) ;

m[q] = p ;
}

while( ~scanf("%s", s ) )
{
if( m.find( s ) != m.end() )
printf("%s\n", m[s].c_str() ) ;
else
printf("eh\n") ;
}

return 0 ;
}

『陸』 急急急!!!!用c語言實現字典 要求:用無序雙向循環鏈表實現字典的基本操作如下

#include <stdafx.h> //這行是VC編譯時要的頭文件,你若TC就不要本行了
#include <stdio.h>

typedef struct dictnode{char *key; char *value; dictnode *pre; dictnode *next;} DictNode;

DictNode *pHead = NULL;

//(1)make:構造空的字典
int make()
{
if(pHead)return -1;
pHead = (DictNode*)malloc(sizeof(DictNode));
memset(pHead,0,sizeof(DictNode));
pHead->pre = pHead;
pHead->next = pHead;
return 0;
}

//(2)size:返回字的字典中記錄數
int size()
{
int i;
DictNode*p;
for(i=0,p=pHead; p->next!=pHead; p=p->next,i++);
return i;
}

//(3)IsEmpy:如果字典為空則返回真,否則返回假
int IsEmpy()
{
return (pHead->pre==pHead);
}

//(4)Clear:將字典重置為空
void Clear()
{
DictNode* p,*ptmp;
for(p=pHead->next; p!=pHead ; )
{
ptmp = p;
p = p->next;
free(ptmp->key);
free(ptmp->value);
free(ptmp);
}
pHead->next = pHead->pre = pHead;//最後一個空節點也是第一個節點
}

//(5)Insert:插入記錄到字典
int Insert(char *key,char*value)
{
DictNode* p, *ptmp;
if(!key||!value||!*key||!*value) return -100;//調用錯誤
ptmp = (DictNode*)malloc(sizeof(DictNode));
if(!ptmp) return -2; //內存不足這種極端的情況很難出現,但有可能
memset(ptmp,0,sizeof(DictNode));
ptmp->key =(char*) malloc(strlen(key)+1);
if(!ptmp->key){free(ptmp);return -2;} //內存不足這種極端的情況很難出現,但有可能
strcpy(ptmp->key,key);
ptmp->value = (char*)malloc(strlen(value)+1);
if(!ptmp->value){free(ptmp->key);free(ptmp); return -2;} //內存不足這種極端的情況很難出現,但有可能
strcpy(ptmp->value,value);
for(p=pHead->next; p->next!=pHead; p=p->next) if(p->key&&!strcmp(p->key,key)) return 1;//記錄存在,插入失敗
ptmp->next = pHead; pHead->pre = ptmp;
ptmp->pre = p; p->next = ptmp;
return 0;//操作成功返回0
}

//(6)remove:與給定關鍵字的記錄相同則刪除,該記錄被返回,否則字典保持不變
DictNode* remove(char *key)
{
DictNode* p;
for(p=pHead->next; p!=pHead&&strcmp(p->key,key); p=p->next);
if(p==pHead) return NULL;
p->pre->next = p->next;
p->next->pre = p->pre;
p->pre = p->next = NULL;
return p;//結點p的空間(key value p三個)沒有釋放,外面要接收返回值並主動釋放結點空間或做別的處理如插入另一表中等
}

//(7)IsPrensent:如果存在與給定關鍵字匹配的記錄則返回真,否則返回假
int IsPrensent(char *key)
{
DictNode* p;
for(p=pHead->next; p!=pHead&&strcmp(p->key,key); p=p->next);
return (p!=pHead);
}

//(8)Find:如果存在與給定關鍵字相同的記錄,則返回記錄;如果沒有找到,則返回空
DictNode* Find(char *key)
{
DictNode* p;
for(p=pHead->next; p!=pHead&&strcmp(p->key,key); p=p->next);
if(p==pHead) return NULL;
return p; //不要對Find返回的記錄key值做變更,value值可以修改,value加長時要重新分配空間。因為記錄還在字典鏈表中
}

void main()
{
const char *prtstr = "****************************";
DictNode* ptmp;
char keybuf[80];
char valuebuf[1024];
int c;
make();
while(1)
{
system("cls");//清屏
printf("%s 選擇菜單 %s",prtstr,prtstr);
printf("\n\tF---詞條查找\n\tI---插入新詞條\n\tR---刪除詞條\n\tC---清空字典\n\tS---顯示字典詞條數\n\tQ---退出\n");
printf("請選擇操作菜單:");
fflush(stdin);
c = getchar();
if(c>='a'&&c<='z') c -= ('a'-'A');//換大寫
if(c!='F'&&c!='I'&&c!='R'&&c!='C'&&c!='S'&&c!='Q') continue;
fflush(stdin);
switch(c)
{
case 'F':
printf("詞條查找:\n請輸入Key值:");scanf("%s",keybuf);
fflush(stdin);
ptmp = Find(keybuf);
if(ptmp){printf("Key:%s Value:%s",ptmp->key,ptmp->value);}
else{printf("沒找到詞條:%s,你可以先選擇插入這個新詞條",keybuf);}
break;
case 'I':
printf("插入新詞條:\n請輸入Key值:");scanf("%s",keybuf);
fflush(stdin);
if(IsPrensent(keybuf)){printf("詞條%s已存在\n",keybuf);}
else
{
printf("請輸入它的解釋:");gets(valuebuf);
if(!Insert(keybuf,valuebuf))printf("插入成功\n");
else printf("插入失敗\n");
}
break;
case 'R':
printf("刪除詞條:\n請輸入Key值:");scanf("%s",keybuf);
fflush(stdin);
ptmp = remove(keybuf);
if(ptmp)
{
free(ptmp->value);free(ptmp->key);free(ptmp);
printf("記錄key:[%s]已刪除\n",keybuf);
}
else
printf("未找到待刪除的記錄key:[%s]\n",keybuf);
break;
case 'C':
printf("清空字典:\n真的要清嗎?\n請輸入Yes以確認刪除操作(首字母大寫):");scanf("%s",keybuf);
fflush(stdin);
if(strcmp(keybuf,"Yes")){printf("放棄了清空操作\n");}
else {Clear();printf("Ok,你堅持操作,現在字典已清空了\n");}
break;
case 'S':
printf("顯示字典詞條數:\n當前詞條總數:%d\n", size());
break;
case 'Q':
Clear(); free(pHead);
printf("Byebye");
exit(0);
}
printf("\n按回車鍵繼續......");
fflush(stdin);
getchar();
}
}
//VC7.1 下調試通過,運行功能正常

『柒』 c語言雙關鍵字排序

提供一個思路,當然這個思路可能不是最優的首先按第一個關鍵字x,基於鏈表排序,排序完成之後這些雙關鍵字在每一段當中是有序的。然後把整條鏈表按照第一個關鍵字斷開,即關鍵字x為1的一條鏈表,為2的一條,依此類推。然後分別在每一段當中按照第二個關鍵字排序,最後輸出的時候合並就可以了。

『捌』 C語言雙關鍵字排序誰會~進來看下

我的想法是,用一種穩定的排序方法(我用的是改進後的冒泡法),先對次要關鍵字排序,然後對主要關鍵字排序,代碼如下,其中Sort_1是將兩次排序整合到了一起,Sort則是直接做兩次排序,建議使用Sort。

#include <stdio.h>

typedef struct _student {
int ID,Class;
}student;

//第一種方法,需要調用兩次
void Sort_1(student *s,int count,int field) {
int i,j,k;
student tmp,*c=(student*)((int*)s+field);
for (i=0;i<count-1;i++) {
for (k=i,j=i+1;j<count;j++)
if (*(int*)(c+k)>*(int*)(c+j))k=j;
if (k!=i)
tmp=s[k],s[k]=s[i],s[i]=tmp;
}
}

//第二種方法,直接兩次排序
void Sort(student *s,int count) {
int i,j,k;
student tmp;
for (i=0;i<count-1;i++) {
for (k=i,j=i+1;j<count;j++)
if (s[k].ID>s[j].ID)k=j;
if (k!=i)
tmp=s[k],s[k]=s[i],s[i]=tmp;
}
for (i=0;i<count-1;i++) {
for (k=i,j=i+1;j<count;j++)
if (s[k].Class>s[j].Class)k=j;
if (k!=i)
tmp=s[k],s[k]=s[i],s[i]=tmp;
}
}

int main() {
int i;
student a[5]={
{1001,1},{1002,1},{1003,2},
{2001,1},{2002,2},
};
//Sort(a,5);
Sort_1(a,5,0);
Sort_1(a,5,1);
for (i=0;i<5;i++)
printf("Class:%d\tID:%d\n",a[i].Class,a[i].ID);
system("pause");
return 0;
}

『玖』 c語言做小詞典

/*基本的庫函數*/
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define szWORD 32
#define szSTRN 224
#define szITEM sizeof(struct TItem)
char fileDict[szSTRN];

typedef struct TItem {
char word[szWORD];
char mean[szSTRN];
} Item;

fpos_t lookup(char *word, char *mean)
{
FILE * f = 0; Item i;
int r = 0; fpos_t p = 0;
if(!word) return 0;
f = fopen(fileDict, "rb");
if (!f) return 0;
while(!feof(f)) {
fgetpos(f, &p);
r = fread(&i, szITEM, 1, f);
if(r < 1) break;
if(i.word[0] == 0) continue;
if(strcmp(i.word , word)) continue;
if(mean) strcpy(mean, i.mean );
fclose(f);
return p+1;
}
fclose(f);
return 0;
}

void append(void)
{
Item i; FILE * f = 0; fpos_t p = 0;
memset(&i, 0, szITEM);
printf("請輸入單詞:"); scanf("%s", i.word );
p = lookup(i.word, 0 );
if(p) {
printf("字典內已經有該單詞記錄!\n");
return;
}
printf("請輸入釋義,按回車結束:");
fflush(stdin);
gets(i.mean );
f = fopen(fileDict, "ab");
fwrite(&i, szITEM, 1, f);
fclose(f);
printf("詞條已新增\n");
}

void erase(void)
{
Item i; FILE * f = 0; fpos_t p = 0;
memset(&i, 0, szITEM);
printf("請輸入單詞:"); scanf("%s", i.word );
p = lookup(i.word, 0 );
if(p==0) {
printf("字典內沒有該單詞記錄!\n");
return;
}
p--;
memset(&i, 0, szITEM);
f = fopen(fileDict, "rb+");
fsetpos(f, &p);
fwrite(&i, szITEM, 1, f);
fclose(f);
printf("詞條已刪除\n");
}

void edit(void)
{
Item i; FILE * f = 0; fpos_t p = 0;
memset(&i, 0, szITEM);
printf("請輸入單詞:"); scanf("%s", i.word );
p = lookup(i.word, 0 );
if(p==0) {
printf("字典內沒有該單詞記錄!\n");
return;
}
p--;
printf("請輸入釋義,按回車結束(輸入abort放棄修改):");
fflush(stdin);
gets(i.mean );
if(strstr(i.mean ,"abort")) {
printf("已放棄修改!\n");
return ;
}
f = fopen(fileDict, "rb+");
fsetpos(f, &p);
fwrite(&i, szITEM, 1, f);
fclose(f);
printf("詞條已保存\n");
}

void query(void)
{
Item i; fpos_t p = 0;
memset(&i, 0, szITEM);
printf("請輸入單詞:"); scanf("%s", i.word );
p = lookup(i.word, i.mean );
if(p==0) {
printf("字典內沒有該單詞記錄!\n");
return;
}
printf("【詞條】%s\n【釋義】%s", i.word , i.mean );
}

void set(void)
{
int cmd = 0;
printf("當前字典為%s,需要改變嗎(選擇y或Y改變)?", fileDict);
cmd = getch();
if(cmd == 'y' || cmd == 'Y') {
printf("請輸入字典文件名稱(包含路徑):");
scanf("%s", fileDict);
printf("設置成功!\n");
}
}
int main(int argc, char * argv[])
{
int cmd = 0;
if(argc >1)
strcpy(fileDict, argv[1]);
else
strcpy(fileDict, "c:\\dict.txt");
/*end if*/
for(;;) {
printf("\n\
************************\n\
** 歡迎使用迷你字典!**\n\
************************\n\
** 0 - 設置字典 **\n\
** 1 - 查詢詞條 **\n\
** 2 - 新增詞條 **\n\
** 3 - 編輯詞條 **\n\
** 4 - 刪除詞條 **\n\
** 5 - 退出字典 **\n\
************************\n");
cmd = getch() - '0';
switch(cmd) {
case 0: set(); break;
case 1: query(); break;
case 2: append(); break;
case 3: edit(); break;
case 4: erase(); break;
default: return 0;
}
}
return 0;
}