| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 609 人关注过本帖
标题:[求助]链表结构程序问题
只看楼主 加入收藏
情风留云
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-3-22
收藏
 问题点数:0 回复次数:1 
[求助]链表结构程序问题

#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编辑过]

搜索更多相关主题的帖子: 链表 结构 
2006-04-03 16:19
雨下的时候
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-3-31
收藏
得分:0 

#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); //错误1,拼写错误
}
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"); //错误2,print拼写错误
}
} //错误3,这里有问题


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");
}


————————————————————————————————————
错误太多,书写不规范,很难看啊~~~~~

2006-04-04 00:37
快速回复:[求助]链表结构程序问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024788 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved