链表的逆序输出 递归算法
2013-10-24 21:24
232 查看
// 1233.cpp : Defines the entry point for the console application.//
#include "stdafx.h"#include <stdlib.h>#include <stdio.h>#include <string.h>
struct node{ int value; node* next;};
//链表的逆序输出 递归算法void out(node* head){ if(head->next!=NULL) { out(head->next); } printf("%d\n",head->value);}
int main(int argc, char* argv[]){ node* head=new node(); head->value=1;
node* p=new node(); p->value=2; head->next=p;
node* q=new node(); q->value=3; q->next=NULL;
p->next=q;
out(head); return 0;}
#include "stdafx.h"#include <stdlib.h>#include <stdio.h>#include <string.h>
struct node{ int value; node* next;};
//链表的逆序输出 递归算法void out(node* head){ if(head->next!=NULL) { out(head->next); } printf("%d\n",head->value);}
int main(int argc, char* argv[]){ node* head=new node(); head->value=1;
node* p=new node(); p->value=2; head->next=p;
node* q=new node(); q->value=3; q->next=NULL;
p->next=q;
out(head); return 0;}
相关文章推荐
- 链表的创建、取长、输出、插入、删除、逆序
- 将一个链表逆序并输出
- 删除链表中的重复节点、剩余节点逆序输出
- 单链表逆序或者逆序输出
- 删除链表中的重复节点、剩余节点逆序输出
- 链表的建立、输出、逆序
- C语言数据结构实现链表逆序并输出
- 如何逆序输出一个链表的节点内容
- 剑指Offer03 逆序输出链表&链表逆序
- 浅谈链表 栈 队列 及链表的逆序输出应用
- C语言递归算法系列_ 逆序和正序输出一个整数的每位数 (1)
- 单链表逆序输出
- 26751:线性链表的建立及逆序输出 分数: 100
- java版的单向链表的逆序输出
- 实现链表的逆序输出和删除某节点
- 【链表】逆序输出
- 单向链表逆序输出
- 两种方法实现单向链表的创建、遍历、删除、查找、逆序输出(循环法和递归法)
- 逆序输出递归算法
- [华为机试练习题]24.删除链表中的重复节点、剩余节点逆序输出