c语言中链表建立与处理中的问题
#include <stdio.h>
#include <malloc.h>
LL* creat();
LL* sort(LL *);
void print(LL *);
void main ()
{
typedef struct Linklist
{
struct Linklist * pri=NULL;
struct Linklist * next=NULL;
int number;
}LL;
print(sort(creat()));
}
LL* creat()
{
while (1)
{
LL *new_one=NULL;
LL *head=NULL;
LL *p1=NULL;
int tem=0;
printf("请输入数值");
scanf("%d",&tem);
if(tem<0)
return head;
//建立链表中。。。。。
int n=0;
new_one =(LL *)malloc(sizeof(LL));
//对节点建立关系
if(p1)
{
p1->next=new_one;
new_one->pri=p1;
}
P1=new_one;//保存上一个链表
if(n=1)
{
head=new_one;
}
new_one->number=tem;
}
}
LL* sort(LL *head)
{
int t;
t=0;
LL *p;
if(head=NULL)
printf("出错,请首先建立链表");
//从小到大采用冒泡排序法
for( p=head;*p.next;p=*p.next)
for( p=head;*p.next;p=*p.next)
{
if(*p.number>*(*p.next).number)
{
t=*p.number;
*p.number=*(*p.next).number;
*(*p.next).number=t
}
}
return head;
}
void print(LL *p)
{
printf("从小到大输出");
while(*p.next)
{
printf("d%",*p.number);
p=*p.next;
}
printf("从大到小输出");
while(*p.pri)
{
printf("%d",*p.number);
p=*p.pri;
}
}
以上是代码,错误是:
C:UsersJDesktoptext_2.c(3) : error C2143: syntax error : missing '{' before '*'
C:UsersJDesktoptext_2.c(4) : error C2143: syntax error : missing '{' before '*'
C:UsersJDesktoptext_2.c(4) : error C2143: syntax error : missing ')' before '*'
C:UsersJDesktoptext_2.c(4) : error C2143: syntax error : missing '{' before '*'
C:UsersJDesktoptext_2.c(4) : error C2059: syntax error : ')'
C:UsersJDesktoptext_2.c(4) : error C2059: syntax error : ';'
C:UsersJDesktoptext_2.c(5) : error C2143: syntax error : missing ')' before '*'
C:UsersJDesktoptext_2.c(5) : error C2143: syntax error : missing '{' before '*'
C:UsersJDesktoptext_2.c(5) : error C2059: syntax error : ')'
C:UsersJDesktoptext_2.c(5) : error C2059: syntax error : ';'
C:UsersJDesktoptext_2.c(11) : error C2143: syntax error : missing ';' before '='
C:UsersJDesktoptext_2.c(11) : error C2059: syntax error : '='
C:UsersJDesktoptext_2.c(16) : error C2143: syntax error : missing ')' before '('
C:UsersJDesktoptext_2.c(16) : error C2143: syntax error : missing ')' before '('
C:UsersJDesktoptext_2.c(16) : error C2091: function returns function
C:UsersJDesktoptext_2.c(16) : error C2091: function returns function
C:UsersJDesktoptext_2.c(16) : error C2059: syntax error : ')'
C:UsersJDesktoptext_2.c(16) : error C2059: syntax error : ')'
C:UsersJDesktoptext_2.c(17) : error C2059: syntax error : '}'
C:UsersJDesktoptext_2.c(53) : error C2143: syntax error : missing '{' before '*'
C:UsersJDesktoptext_2.c(53) : error C2143: syntax error : missing ')' before '*'
C:UsersJDesktoptext_2.c(53) : error C2143: syntax error : missing '{' before '*'
C:UsersJDesktoptext_2.c(53) : error C2059: syntax error : ')'
C:UsersJDesktoptext_2.c(54) : error C2054: expected '(' to follow 'head'
C:UsersJDesktoptext_2.c(79) : error C2143: syntax error : missing ')' before '*'
C:UsersJDesktoptext_2.c(79) : error C2143: syntax error : missing '{' before '*'
C:UsersJDesktoptext_2.c(79) : error C2059: syntax error : ')'
C:UsersJDesktoptext_2.c(80) : error C2054: expected '(' to follow 'p'
执行 cl.exe 时出错.
text_2.exe - 1 error(s), 0 warning(s)
编译器:vc++6.0
目的:建立一个链表,输入负数结束,实现升序和降序输出
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论