二叉树先序遍历(递归)

#include<stdio.h> #include<stdlib.h> typedef struct binarytree { int data; struct binarytree *lchild; struct binarytree *parent; struct binarytree *rchild; }BT; BT * init_bt() { BT *tree=(BT *)malloc(sizeof(BT)); tree->parent=NULL; tree->lchild=NULL; tree->rchild=NULL;...
数据结构 | 2013-12-26 22:16 | 阅读 1134 次 | 评论 0 条

进出栈

问题描述:火车分n小节,从头开始进站出站,有可能的顺序 #include<fstream> #include<sstream> #include<iostream> #include<stack> using namespace std; int main(){ ifstream in("rail.txt"); for(int n,line=0;in>>n&amp;&amp;n&amp;&amp;in.ignore();){ cout<<(line++ ? "\n":""); for(string s;getline(in...
数据结构 | 2013-12-25 22:12 | 阅读 1844 次 | 评论 0 条

矩阵加法

#include<stdio.h> #include<stdlib.h> #include<malloc.h> #include<string.h> typedef struct node { int i; int j; float value; struct node *down; struct node *right; }NODE,*NODEP; typedef struct matrix { int m;int n;int t; NODEP *row; NODE...
数据结构 | 2013-12-24 10:07 | 阅读 1954 次 | 评论 0 条
最新评论