加载中
判断一颗二叉树是不是平衡AVL

#include <stdio.h> #include <cmath> //二叉树结点 typedef struct binary_tree_node_t{   binary_tree_node_t * left;   binary_tree_node_t * right;   int  elem; }; //方法1...

2014/09/01 20:47
73
判断一颗二叉树是不是二叉排序树BST

#include <stdio.h> #include <climits> //二叉树结点 typedef struct binary_tree_node_t{   binary_tree_node_t * left;   binary_tree_node_t * right;   int  elem; }; //如果...

2014/09/01 20:28
515
图的dfs输出全排列

#include <stdio.h> #include <string.h> #include <vector> using namespace std; int n; int visit[100];//是否访问过 vector<int> vi;//排列的结果 void dfs(int level ){ ...

2014/09/01 17:25
204
5.5.2 最小的N个和

#include <stdio.h> #include <queue> #include <algorithm> #define MAX 1000 using namespace std; int n; int A[MAX], B[MAX]; typedef struct node{   int sum;//sum =...

2014/08/31 16:51
53
5.1遍历二叉树

#include <stdio.h> #include <stack> #include <queue> using namespace std; //结点的数据 typedef int tree_node_elem_t; //二叉树结点 typedef struct binary_tree_node_t{   ...

2014/08/31 12:14
84
4.1栈

未做: C语言实现栈、队列 汉诺塔 void hanoi(int n, char x, char y, char z){   if(n == 1){//已经轮到移动1号盘,即最后一步了     printf("%d   from %c to %c\n", 1, x...

2014/08/31 10:01
68
1083 List Grades

题本身很水,但逗比的过程中发现了: 1: 不要用strcmp比较两个数字型字符串的大小: printf("%d\n",strcmp("60","100"));//return 1即 60 > 100,因为strcmp 比较首字符发现不等就返回...

2014/08/28 14:59
64
1080 Graduate Admission

排序题, 关键是要想到排序后,是按照学生的志愿来遍历,所有志愿都拒绝了,这个学生就是reject; 所有学生都录取或reject了,就停止; 两个结构体是一边写代码时一边完善的: typedef struc...

2014/08/28 11:37
56
1079 Total Sales of Supply Chain

结构体+树的BFS就过了 #include <stdio.h> #include <vector> #include <queue> using namespace std; int n; double p, r; double totalSale; typedef struct node{   int id;...

2014/08/28 10:05
49
1072 部分正确

自己想到了是多源点求最短路径问题,用Dijkstra实现了1个多小时,还是2个4分case错误! 1: 初始化不应该用memeset设-1, 判断里面烦死了,图的算法还得练,不熟 2 :居然没有round函数,inc...

2014/08/26 20:20
64
1071 Speech Patterns

模拟题 1: map默认就是按照key排序的 2:添加元素时,可以直接map[string]++; #include <stdio.h> #include <string> #include <iostream> #include <map> using namespace std; map<s...

2014/08/25 21:16
61

没有更多内容

加载失败,请刷新页面

返回顶部
顶部