#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void CreateList();
void InsList(int i,char x);
void DelList(char x) ;
void SearchList(char x) ;
typedef struct linknode
{char data;
struct linknode *next;
}node;
node *head;
int n=0;
void main()
{ int choice,i,j=1;
char x;
head=NULL;
while(j)
{printf("\n\n\n\n");
printf("1:please creatlist\n");
printf("2:please insert a elemtype\n");
printf("3:please dellist a elemtype\n");
printf("4:please searchlist a elemtype\n");
printf("5:please return\n");
printf("choice(1-5)\n");
scanf("d%",&choice);
if(choice==1)
CreateList();
else if(choice==2)
{printf("pleae get a position and a elemtype(i,x):\n");
scanf("%d,%c,&i,&x");
InList(i,x);
}
else if(choice==3)
{printf("please get a delelemtype:\n");
scanf("%c",&x);
DelList(x);
}
else if(choice==4)
{printf("please get a searchelemtype:\n");
scanf("%c",&x);
SearchList(x);
}
else if(choice==5)
{print("rutrun 0\n");
}
}
CreateList()
{
node *p,*s;
char x;
int z=1;
head=new node;
p=head;
while(z=1)
{printf("creatlist:\n");
scanf("%c",&x);
getchar();
if (x!='x')
{s=new node;
n++;
s->data=x;
p->next=s;
s->next=NULL;
p=s;
}
else z=0;
}
}
void InsList(int i, char x)
{node *p,*s;
int j
s=new node;
n++;
s->data=x;
if(i==0)
{s->next=head;
head=s;
}
else
{p=head;j=1;
while (p!=NULL&&j<1)
{j++;
p=p->next;
}
if(p!=NULL)
{s-next=p->next;
p->next=s;
}
else
printf("can not find\n");
}
}
void DelList(char x)
{node *p;*q;
if(head==NULL)
{printf("errow\n");
return;
}
if(head->next==NULL)
{printf("The list is null");
return;
}
q=head;
p=head->next;
while(p!=NULL&&p-data!=x)
{q=p;
p=p->next;
}
if(p!=NULL)
{q->next=p->next;
delete p;
n--;
printf("delete sucecc\n");
}
else
printf("not find\n");
}
void SearchList(char x)
{node *p;
int i=1;
if (head==NULL)
{printf("over\n");
return;
}
if (head->next==NULL)
{printf("The list is NULL\n");
return;
}
p=head->next;
while(p!=NULL&&p->data!=x)
{p=p->next;
i++;
}
if (p!=NULL)
printf("find x in :i,x\n") ;
else
printf("not find\n");
}
出现两个错误 1, Statment missing
2, compound statment missing
地点在这个括号 void CreateList() // 建立线性表
{
第二个地点在最后的括号
请求为什么呀
[此贴子已经被作者于2006-4-3 16:29:50编辑过]