#include<iostream>#include<string>#define ERROR 0#define OK 1using namespace std;typedef struct node{ char word[20]; char tran[20]; node *next;}ListNode,*List;void creat(List &L){ L=new ListNode; L->next=NULL;}int real(char s[],List L){ ListNode *p=L->next; while(p!=NULL){ if(s==p->word){ printf("error"); return ERROR; } p=p->next; } return OK;}void display(List L){ ListNode *p=L->next; while(p!=NULL){ cout<<p->word<<' '<<p->tran<<endl; p=p->next; }}void insert(List &L){ char str1[20]={'N'}; ListNode *p=L,*s; int j=1,i=1,k=1; while(j){ s=new ListNode; cin>>s->word>>s->tran; if(strcmp(s->word,str1)==0){ printf("添加完成"); j=0; break; } i=real(s->word,L); if(i==0) printf("error\n"); else{ s->next=p->next; p->next=s; k++; printf("OK\n"); } }}void main(){ ListNode *L; creat(L); insert(L); display(L);}
目前暂无任何回答
- 0 回答
- 0 关注
- 924 浏览
添加回答
举报
0/150
提交
取消