#include "stdafx.h"
#include"malloc.h"
typedef struct node
{
int data;
struct node *next;
}Node,*pNode;
pNode createlist()
{
int i,len;
pNode head=(pNode)malloc(sizeof(Node));
pNode end=head;
end->next=NULL;
printf("\n请输入结点个数:");
scanf("%d",&len);
for(i=1;i<=len;i++)
{
pNode New=(pNode)malloc(sizeof(Node));
printf("\n请输入第%d个结点值:",i);
scanf("%d",&New->data);
end->next=New;
New->next=NULL;
end=New;
}
return head;
}
void select(pNode test)
{
pNode p=test->next;
printf("此单链表中的值有:");
while(p!=NULL)
{
printf("%d ",p->data);
p=p->next;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
pNode test=createlist();
select(test);
return 0;
}