// FileDownloader.cpp : 定义控制台应用程序的入口点。
//头插法,插入新元素
//
#include "stdafx.h"
#include
#include
#include
struct node
{
int num;
struct node *next;
}*head,LinkList;
typedef struct node item;
item append(node *head,int num)
{
item *temp,*right;
temp=(item*)malloc(sizeof(item));
temp->num=num;
right=(struct node*)head;
right=temp;
right->next=head;
return *right;
}
int _tmain(int argc, _TCHAR* argv[])
{
item *cur ,*head,cur2,*cur3;
int i ;
head=NULL;
for(i=1;i<=10;i++)
{
cur=(item*)malloc(sizeof(item));
cur->num=i;
cur->next=head;
head=cur;
}
cur=head;
//item i= append(cur,333);
cur2=append(cur,333);
cur3=cur2.next;
//不得已为之
printf_s("%d\n",cur2.num);
while (cur3->next!=NULL)
{
printf_s("%d\n",cur3->num);
cur3=cur3->next;
}
//while (cur)
//{
//printf_s("%d\n",cur->num);
//cur=cur->next;
//}
system("pause");
return 0;
}