|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
#include<stdlib.h>
typedef struct LNode
{
int data;
struct LNode *next;
}LNode;
typedef struct LNode* LinkList;
LNode* CreateList(int n)
{
LNode *p=NULL,*head;
head=(LinkList)malloc(sizeof(LNode));
p=head;
LNode *s;
int i = 1 ;
for(n != 0)
{
while( i <= n )
{
s=(LinkList)malloc(sizeof(LNode));
s->data=i++;
p->next=s;
p=s;
}
s->next=head->next;
}
return s->next;
}
int main()
{
int n=41;
int m=3;
int i;
LNode *p=CreateList(n);
LNode *temp;
m=m%n;
while(p!=p->next)
{
for(i=1;i<m-1;i++)
{
p=p-> next;
}
printf("%d",p->next->data);
temp=p->next;
p->next=temp->next;
free(temp);
p=p->next;
}
printf("%d",p->data);
return 0;
}
--------------------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.c
C:\Users\LSZ\Desktop\1.c(15) : error C2275: 'LNode' : illegal use of this type as an expression
C:\Users\LSZ\Desktop\1.c(7) : see declaration of 'LNode'
C:\Users\LSZ\Desktop\1.c(15) : error C2065: 's' : undeclared identifier
C:\Users\LSZ\Desktop\1.c(16) : error C2143: syntax error : missing ';' before 'type'
C:\Users\LSZ\Desktop\1.c(17) : error C2143: syntax error : missing ';' before ')'
C:\Users\LSZ\Desktop\1.c(17) : error C2143: syntax error : missing ';' before ')'
C:\Users\LSZ\Desktop\1.c(17) : warning C4552: '!=' : operator has no effect; expected operator with side-effect
C:\Users\LSZ\Desktop\1.c(19) : error C2065: 'i' : undeclared identifier
C:\Users\LSZ\Desktop\1.c(21) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct LNode *'
C:\Users\LSZ\Desktop\1.c(22) : error C2223: left of '->data' must point to struct/union
C:\Users\LSZ\Desktop\1.c(23) : warning C4047: '=' : 'struct LNode *' differs in levels of indirection from 'int '
C:\Users\LSZ\Desktop\1.c(24) : warning C4047: '=' : 'struct LNode *' differs in levels of indirection from 'int '
C:\Users\LSZ\Desktop\1.c(26) : error C2223: left of '->next' must point to struct/union
C:\Users\LSZ\Desktop\1.c(28) : error C2223: left of '->next' must point to struct/union
C:\Users\LSZ\Desktop\1.c(28) : warning C4033: 'CreateList' must return a value
执行 cl.exe 时出错.
1.exe - 1 error(s), 0 warning(s)
|
|