点击打开链接
求MST的最长边~
prim
#include
#include
#include
#include
#define Min(a,b) (a)<(b)?(a):(b)
using namespace std;
const int INF = 1000000000;
const int maxn = 2000 + 5;
struct pto
{...
分类:
其他好文 时间:
2014-06-11 06:45:17
阅读次数:
235
按先序遍历创建一棵树,以层次遍历输出
样例输入
A B # D # # C E # # F # #
样例输出
LevelOrder: A B C D E F
代码:
#include
#include
using namespace std;
struct node { //表示一个树上的节点
char ch;
nod...
分类:
其他好文 时间:
2014-06-10 15:58:02
阅读次数:
295
队列常常也使用链式存储的方式来实现。为了方便操作,同顺序存储一样,我们要维护一个头指针和一个尾指针。如下图:
在链式队列中显然不会出现假溢出的情况。但在出队时,要及时释放内存。由于在队列的实现:顺序队列中,对队列的描述已经很清楚了。就闲话不多说,直接上代码:
类定义和类实现
#include
#include
using namespace std;
typedef int ELem...
分类:
其他好文 时间:
2014-06-10 08:04:30
阅读次数:
253
题意:求在可以一秒沿着既定方向走1到3步和向左或右转90度的情况下,从起点到终点的最短时间
思路:坑的是这机器人还有体积,所以不能走到边界,然后就是单纯的BFS
#include
#include
#include
#include
#include
using namespace std;
const int MAXN = 110;
struct node {
int x,y;...
分类:
其他好文 时间:
2014-06-10 07:59:51
阅读次数:
256
贪心算法,每条路径最短2格,故前k-1步每次走2格,最后一步全走完由于数据比较小,可以先打表#include
#include #include #include using namespace std;typedef pair Point;int main(){
int n, m, k, f...
分类:
其他好文 时间:
2014-06-10 00:33:15
阅读次数:
302
二叉链表的C语言描述基本运算的算法——建立二叉链表、先序遍历二叉树、中序遍历二叉树、后序遍历二叉树、后序遍历求二叉树深度#include#includeusing
namespace std;class Tree{private: struct Node { char da...
分类:
其他好文 时间:
2014-06-09 18:39:49
阅读次数:
310
#include using namespace std;struct Node{ Node
*next; int elem;};void creatList(Node* &head){ head = new Node; int elem;
cin>>elem; ...
分类:
其他好文 时间:
2014-06-09 17:50:43
阅读次数:
219
#include using namespace std;struct Node{ Node
*next; int elem;};void creatList(Node* &head){ head = new Node; int elem;
cin>>elem; ...
分类:
其他好文 时间:
2014-06-09 16:07:55
阅读次数:
229
#include ssize_t recvfrom(int sockfd, void *buff,
size_t nbytes, int flags, struct sockaddr *from, socklen_t *addrlen);ssize_t
sendto(int sockfd, cons...
分类:
其他好文 时间:
2014-06-09 13:22:32
阅读次数:
319