中序线索二叉树的建立 #include<stdio.h> #include<stdlib.h>//中序建立二叉树 typedef struct node{ struct node *left,*right; int data; int rTag,lTag;}BNode;BNode* pre=NULL;//pre总是指向其前一个结点 ...
按顺序输入建立二叉树 二叉树的顺序存储是指用一组地址连续的存储单元依次自上而下、自左向右存储完全二叉树上的结点元素 1 #include<stdio.h> 2 #include<stdlib.h> 3 typedef struct btree 4 { 5 int data; 6 struct btree *right,*left; 7 ...
用循环链表实现约瑟夫环 1 #include <stdio.h> 2 #include <stdlib.h> 3 typedef struct node{ 4 int number; 5 struct node * next; 6 }node; 7 node * initLink(int n){ 8 node * head=(...
用二叉链表建立二叉树 1 #include<stdio.h> 2 #include<stdlib.h> 3 typedef struct node 4 { 5 int data; 6 struct node *l,*r; 7 8 }tree; 9 tree* Creattree(void)//层次建立二叉树 10 {...
最短路径----迪杰斯特拉算法解析 1 #include<stdio.h> 2 int map[1005][1005],vis[1005],dis[1005],min,n,m; 3 #define max 0x3f3f3f3f//这里表示无穷大,注意如果调用limits.h里面的INT_MAX,他会把这个当2147483647算; 4 void Dijkstra(int x)//这里用迪...
关于有头结点链表的创建算法及基础功能打的实现 这里是有头结点的链表创建: 1 #include<stdio.h> 2 #include<stdlib.h> 3 typedef struct Link 4 { 5 int data; 6 struct Link *next; 7 }lk;//定义lk为struct link类型; 8 ...
Message Decoding 简单的代码,希望大家加以指点一二#include <bits/stdc++.h>using namespace std;int main(){ char k[26],c; int i; for(i='a'; i<='z';i++) cin>>k[i]; getchar(); while((...
Jungle Roads(最小生成树计算最短路径) 2019-03-07 1 #include <bits/stdc++.h> 2 using namespace std; 3 #define max 0x3f3f3f3f//无穷大; 4 int tre[30][30],val[30],vis[30],n; 5 void prim()//本算法是采用prim来写最小生成树的,当然还有其他算法...