Dijkstra(迪杰斯特拉)算法是典型的单源最短路径算法,用于计算一个节点到其他所有节点的最短路径。主要特点是以起始点为中心向外层层扩展,直到扩展到终点为止。/*图的邻接矩阵表示*/typedef struct _graph{ int vexs[MAX]; int vnum; int enum.....
分类:
其他好文 时间:
2014-08-14 23:49:16
阅读次数:
203
#:会把参数转换为字符串#define STR(x) #x#define MAX 100STR(MAX) 会被扩展成"MAX"这样就有一个缺陷,如果入参为宏,并不能打印出宏的值(比如上一个例子,只打印出了MAX,并没有打印出MAX的值)可以将宏扩展下#define _STR(x) ...
分类:
编程语言 时间:
2014-08-14 23:40:26
阅读次数:
1101
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1709题意: 给N个整数,每个数只能使用一次。将他们组合起来,最后看在1~sum(a[1]..a[N])这些数里有多少数是这N个数组合不出来的. 先输出这些数的个数,再将这些数输出来。如果个数是0,那.....
分类:
其他好文 时间:
2014-08-14 23:35:26
阅读次数:
355
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol...
分类:
其他好文 时间:
2014-08-14 23:26:46
阅读次数:
219
为了避免缓冲区溢出,从终端读取输入时应当用fgets()代替gets()函数。但是这也将带来一个问题,因为fgets()的调用格式是:fgets (buf, MAX, fp)fgets (buf, MAX, stdin)buf是一个char数组的名称,MAX是字符串的最大长度,fp是FILE指针。f...
分类:
其他好文 时间:
2014-08-14 23:13:06
阅读次数:
422
Python列表函数和方法python列表中主要有以下函数:cmp(list1,list2)比较两个列表的元素len(list)列表元素的个数max(list)返回列表元素的最大值min(list)返回列表元素的最小值list(seq)将元组转换成列表---------------------------------我是华丽的分割线--------------------..
分类:
编程语言 时间:
2014-08-14 21:01:49
阅读次数:
200
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path....
分类:
其他好文 时间:
2014-08-14 20:50:59
阅读次数:
192
#include
#include
int main()
{
int i,len;
char str[110],max;
while(~scanf("%s",str))
{
len=strlen(str);
max='A';
for(i=0;imax)
max=str...
分类:
其他好文 时间:
2014-08-14 20:47:39
阅读次数:
262
LRJ算法入门经典第二版上面写错了,害得我想了半天。。。
V : 点数, E :边数 F :面数
欧拉公式 V - E + F = 2;
V = n + n / 4 sum(i * (n - 2 - i)); [ 0
E = n + n / 2 sum((i * (n - 2 - i ) + 1); [ 0
代码实现:
#include
#include
#include
#...
分类:
其他好文 时间:
2014-08-14 20:36:59
阅读次数:
280
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ...
分类:
其他好文 时间:
2014-08-14 20:20:09
阅读次数:
206