题目1511:从尾到头打印链表
2015-01-31 19:29
330 查看
写的双向链表RE了,不知道肿么了,只好随手改了一个头插
#include<cstdio> #include<cstring> #include<cstdlib> typedef struct node { int num; struct node *next; //struct node *pre; }SqList; SqList *creat() { SqList *p1,*p2,*temp; p1=(SqList *)malloc(sizeof(SqList)); scanf("%d",&p1->num); // p2->next=p1; p2=NULL; p1->next=p2; p2=p1; //p2->pre=NULL; p1=(SqList *)malloc(sizeof(SqList)); while(scanf("%d",&p1->num) && p1->num != -1) { // temp=p2; p1->next=p2; p2=p1; p1=(SqList *)malloc(sizeof(SqList)); } return p2; } int main() { SqList *List; List = creat(); while(List != NULL) { printf("%d\n",List->num); List=List->next; } return 0; }
相关文章推荐
- 九度OJ-题目1511:从尾到头打印链表
- 剑指offer-5/题目1511:从尾到头打印链表
- 九度oj_题目1511:从尾到头打印链表
- 【九度】题目1511:从尾到头打印链表
- 九度_题目1511:从尾到头打印链表
- 题目1511:从尾到头打印链表
- [Jobdu] 题目1511:从尾到头打印链表——单链表的倒置输出
- 剑指Offers 题目1511:从尾到头打印链表
- 题目1511:从尾到头打印链表
- 题目1511:从尾到头打印链表
- 题目1511:从尾到头打印链表
- 【剑指Offer面试编程题】题目1511:从尾到头打印链表--九度OJ
- 题目1511:从尾到头打印链表
- 题目1511:从尾到头打印链表
- 题目1511:从尾到头打印链表
- 题目1511:从尾到头打印链表
- 【剑指Offer面试编程题】题目1511:从尾到头打印链表--九度OJ
- 题目1511:从尾到头打印链表
- 题目1511:从尾到头打印链表
- 题目1511:从尾到头打印链表-九度