您的位置:首页 > 其它

链表的逆序输出 递归算法

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;}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: