上一页 1 ··· 39 40 41 42 43 44 45 46 47 ··· 50 下一页
摘要: 函数原型:char * strncpy ( char * destination, const char * source, size_t num );功能:从字符串source中复制 num个字符到字符串destination中,返回指向字符串destination的指针。使用注意:destina... 阅读全文
posted @ 2014-08-10 16:41 gongpixin 阅读(489) 评论(0) 推荐(0) 编辑
摘要: 题意:n个农场,求把所有农场连接起来所需要最短的距离。 思路:prim算法 课本代码: 另外,这道题也可以用 Kruskal算法,代码如下: 阅读全文
posted @ 2014-08-08 10:10 gongpixin 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 给int类型赋值的话,0X7FFFFFFF代表最大值,0X80000000代表最小值INT_MAX 代表最大值, INT_MIN 代表最小值 #include#include//INT_MAX与INT_MIN的头文件using namespace std;int main(){ int ima... 阅读全文
posted @ 2014-08-08 09:11 gongpixin 阅读(534) 评论(0) 推荐(0) 编辑
摘要: 标准库在头中定义了两个模板函数std::min() 和 std::max()。通常用它可以计算某个值对的最小值和最大值。可惜在 Visual C++ 无法使用它们,因为没有定义这些函数模板。原因是名字min和max与中传统的min/max宏定义有冲突。为了解决这个问题,Visual C++ 定义了另... 阅读全文
posted @ 2014-08-07 18:06 gongpixin 阅读(7154) 评论(0) 推荐(0) 编辑
摘要: 题意:给出n个村庄之间的距离,再给出已经连通起来了的村庄。求把所有的村庄都连通要修路的长度的最小值。 思路:Kruskal算法 课本代码: 代码2:加了mark标记长度是否存在,代码中 为添加部分 阅读全文
posted @ 2014-08-07 15:41 gongpixin 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 题意: 给两行字符串,第一行为一组变量,第二行时一组约束(每个约束包含两个变量,x y 表示 x #include#includeusing namespace std;int n;int pre[300]; // 存字母入度// 把小写字母的ascii码都包括在内bool has[300];//节... 阅读全文
posted @ 2014-08-07 10:49 gongpixin 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 1.code.cpp:1:21: fatal error: iostream : No such file or directory #include ^compilation terminated.这个情况可能是在代码中写成这样 #include就是在头文... 阅读全文
posted @ 2014-08-06 18:51 gongpixin 阅读(267) 评论(0) 推荐(0) 编辑
摘要: 题意:从 节点1出发,一笔画出 圣诞老人的家(所谓一笔画,就是遍访所有边且每条边仅访问一次)。思路:深度优先搜索(DFS算法)#include#include#includeusing namespace std;int map[6][6];void makemap(){ memset(map... 阅读全文
posted @ 2014-08-06 16:32 gongpixin 阅读(238) 评论(0) 推荐(0) 编辑
摘要: 思路:宽度优先搜索(BFS算法) #include#include#include#includeusing namespace std;int a,b;struct node{ int num; int step;};node que[10000];//默认初始化为0int visit[10000... 阅读全文
posted @ 2014-08-06 14:50 gongpixin 阅读(282) 评论(0) 推荐(0) 编辑
摘要: 使用时注意类型,可见两者皆不可以用int1.pow函数声明: double pow (double base , double exponent); float pow (float base , float exponent);long double pow (... 阅读全文
posted @ 2014-08-06 14:17 gongpixin 阅读(618) 评论(0) 推荐(0) 编辑
上一页 1 ··· 39 40 41 42 43 44 45 46 47 ··· 50 下一页