sdut2117数据结构实验之链表二:逆序建立链表

#include 
#include 
struct node
{
    int data;
    struct node *next;
};
int main()
{
    int i,n;
    struct node *head,*p;
    head=(struct node*)malloc(sizeof(struct node));
    head->next=NULL;
    scanf("%d",&n);
    for(i=0;idata);
        p->next=head->next;
        head->next=p;
    }
    while(p)
    {
        printf("%d ",p->data);
        p=p->next;
    }
    return 0;
}

/***************************************************
User name: TJRAC6015203228魏杰
Result: Accepted
Take time: 0ms
Take Memory: 104KB
Submit time: 2016-11-01 13:31:00
****************************************************/

你可能感兴趣的:(sdut,ACM算法入门)