當前位置:編程學習大全網 - 編程語言 - 編程單詞詞典

編程單詞詞典

# include & ltstdio.h & gt

# include & ltstring.h & gt

# include & ltmalloc.h & gt

# include & ltmath.h & gt

#定義min(A,B)(A & lt;b?答:乙)

#定義max(A,B)(A & lt;b?乙:甲

typedef結構字典

{

char en[30];

char zh[30];

struct Dict * next

} Dict

int main(void)

{

dict * head = 0;

int stu count = 0;//數量

while(1)

{

Printf("輸入操作數:1:詞匯輸入2:瀏覽3:漢英4:英漢5:刪除6:退出:");

int quest

scanf("%d ",& ampquest);

scanf("%*[^\n]”;

if(quest = = 6)break;

else if(quest==1)

{

Dict * new Dict =(Dict *)malloc(sizeof(Dict));

Printf("請輸入中文:");

scanf("%29s ",new dict-& gt;zh);

scanf("%*[^\n]”;

Printf("請輸入英文:");

scanf("%29s ",new dict-& gt;en);

scanf("%*[^\n]”;

//插入鏈表頭,讓最新添加的顯示在最上面,很容易看到效果。

new dict-& gt;下壹個=頭;

head = newDict

++ stu count;

}

else if(quest==2)

{

if(head==0)

Printf("沒話說!\ n ");

其他

{

Printf("開始瀏覽單詞:\ n ");

while(1)

int st=0,en=min(st+10,stu count);

{

Printf ("Browse: %d to %d words \n ",st+1,en);

Dict * stu = head

for(int I = 0;我& ltST;++i)

{

斯圖=斯圖-& gt;接下來;

}

for(int I = ST;我& lten;++i)

{

Printf("中文:%s英文:%s\n ",stu-& gt;恩,斯圖-& gt;zh);

斯圖=斯圖-& gt;接下來;

}

Printf("輸入操作號:1向後翻頁;向前2頁;-1出口:“);

int squest

scanf("%d ",& ampsquest);

scanf("%*[^\n]”;

if(squest==1)

{

如果(恩!= stu count)ST = en;

}

else if(squest==2)

{

st=max(0,ST-10);

}

else if(squest = =-1)break;

en=min(st+10,stu count);

}

}

}

else if(任務==3 ||任務==4 ||任務==5)

{

char a[30];

If(quest==3)printf("請輸入中文詞匯:");

Else if(quest==4) printf("請輸入英文單詞:");

Else if(quest==5) printf("請輸入要刪除的單詞(中英文):");

scanf("%29s ",a);

scanf("%*[^\n]”;

Dict * stu = head

dict * lst stu = 0;

int flag = 0;

而(斯圖!= 0 & amp& ampflag==0)

{

if(quest==3)

{

if(strcmp(a,stu-& gt;zh)==0)

{

Printf("英語:%s\n ",stu-& gt;en);

flag = 1;

}

}

else if(quest==4)

{

if(strcmp(a,stu-& gt;en)==0)

{

Printf("中文是:%s\n ",stu-& gt;zh);

flag = 1;

}

}

else if(quest==5)

{

if(strcmp(a,stu-& gt;en)==0 || strcmp(a,stu-& gt;zh)==0)

{

stu count-;

if(lststu!=0)

lst stu-& gt;next = stu-& gt;接下來;

其他

head = stu-& gt;接下來;

Printf("刪除!\ n ");

flag = 1;

}

}

lststu = stu

斯圖=斯圖-& gt;接下來;

}

如果(標誌==0)

{

Printf("找不到詞匯!\ n ");

}

}

}

返回0;

}

看妳能不能跑。如果有新的需求,我可以繼續寫。代碼應該非常清楚。如果妳有什麽不明白的,我可以給妳解釋。歡迎提問。

  • 上一篇:黑暗天使的電影:黑暗天使
  • 下一篇:法語告白含蓄短句
  • copyright 2024編程學習大全網