书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 19 下一页

2011年12月1日

字符指针变量数组的用法

摘要: 我们知道,char *s="aisdfj"; 是成立的。于是char *s[]={"one", "two", ……}也是成立的。就相当于把char *s看成另外一种类型的变量一样。其实,就这么简单。Sample Inputone + two =three four + five six =zero seven + eight nine =zero + zero =Sample Output39096View Code #include "stdio.h"#include "string.h"ch 阅读全文

posted @ 2011-12-01 16:14 More study needed. 阅读(237) 评论(0) 推荐(0) 编辑

BFS寻求最短距离

摘要: 题目:http://acm.swust.edu.cn/oj/problem/4/这是一道简单的题目,但是可以说明问题了。View Code #include "iostream"#include "string"#include "cstdio"#include "cstring"#include "algorithm"#include "queue"using namespace std;char Map[105][105];int Used[105][105];int D 阅读全文

posted @ 2011-12-01 12:14 More study needed. 阅读(277) 评论(0) 推荐(0) 编辑

DFS遍历整个连通的区域

摘要: DFS在搜索的过程中,可以搜索一大片的连通的区域。题目:http://acm.swust.edu.cn/oj/problem/1/View Code #include<iostream>#include<string.h>using namespace std;int direction[4][2] = {{-1,0},{1,0},{0,-1},{0,1}};int used[1005][85];char map[1005][85];int W, H, i, j, count, Max, tx, ty;void dfs(int i, int j){ int k; cou 阅读全文

posted @ 2011-12-01 12:11 More study needed. 阅读(302) 评论(0) 推荐(0) 编辑

2011年11月27日

map<int,int>和数组

摘要: 我们知道,要是将数组开成int a[0xFFFFFFF]这么大,那是肯定不行。它会提示too big.但是如果用map的话,那就可以了。从这个方面来讲,map就是数组的升级版喽!这个可是我发现的哦。下面简单的给出一个例子来。题目:http://acm.swust.edu.cn/oj/problem/0822/下面给出错误的代码:View Code #include<iostream>#include<cstring>#include<algorithm>using namespace std;#define Max 1500000001int Num[Max 阅读全文

posted @ 2011-11-27 12:04 More study needed. 阅读(4267) 评论(0) 推荐(0) 编辑

矩阵相乘的算法

摘要: 问题:求矩阵相乘后的和。一、最基本的算法下面给出一个例子来说明一下矩阵是如何相乘的。矩阵A为 1 0 2 3 5 6矩阵B为 3 1 2 2 1 3C=A*B = 1*3+0*2+2*1 1*1+0*2+2*3 3*3+5*2+6*1 3*1+5*2+6*3最简单的算法就是用3个for循环就可以搞定了。假设A有ArowNum行, AvolBrow列。B必有AvolBrow行,假设B有BvolNum列。则循环如下: for(int i=0; i<ArowNum; i++) for(int j=0; j<BvolNum; j++) ... 阅读全文

posted @ 2011-11-27 11:21 More study needed. 阅读(1701) 评论(0) 推荐(0) 编辑

2011年11月26日

更加深入的了解Floyd

摘要: 下面来看一道简单的但是有点意思的最短路径的问题。本次用的解法是Floyd.题目:http://acm.swust.edu.cn/oj/problem/0819/在使用Floyd的时候有三点需要注意:一:map[][]数组的初始化 这个是十分的重要的,不然无法Floyd。具体点就是,map[i][i]=0; map[i][j]=INF;二、输入时候的选择性 只有做到这一步,才能保证是最短的,不然不行。具体点就是,if(map[u][v] > w) map[u][v] = map[v][u] = w; 这个主要用在题目中没有说明是否会多次输入同一条边的时候。三、只有一个结点的情况 毫无... 阅读全文

posted @ 2011-11-26 10:46 More study needed. 阅读(248) 评论(0) 推荐(0) 编辑

更加深入的了解SPFA

摘要: SPFA算法是求单源路径的经典算法,就是一点到其它所有点的最短路径。这个类似于Flyod但是效率要高很多。下面给出具体的演示。Minya Konka decided to go to Fuzhou to participate in the ACM regional contest at their own expense.Through the efforts, they got a small amount of financial support from their school, but the school could pay only one of those costs bet 阅读全文

posted @ 2011-11-26 10:38 More study needed. 阅读(364) 评论(0) 推荐(0) 编辑

2011年11月24日

奇怪的字符数组初始化

摘要: 今天做了一个题目,感觉字符数组的初始化有点奇怪,就亲自测试了一下,果不其然。确实很奇怪。这个就要和数组区分开了。一定不能将两者混淆了。下面给出测试的代码,并一一解析。View Code #include "iostream"#include "string"#include "cstring"using namespace std;#define size 10int main(){ char s1[size]="1", s2[size]={0}; for(int i=0; i<10; i++) cout&l 阅读全文

posted @ 2011-11-24 14:37 More study needed. 阅读(648) 评论(0) 推荐(0) 编辑

2011年11月23日

vector的小小应用,大大功能

摘要: DescriptionAs a contestant, you must be familiar with the rules of ACM-ICPC. Teams are ranked according to the most problems solved. Teams who solve the same number of problems are ranked by least total time. The total time is the sum of the time consumed for each problem solved. The time consumed f 阅读全文

posted @ 2011-11-23 13:14 More study needed. 阅读(261) 评论(0) 推荐(0) 编辑

vector中的各种函数演示

摘要: 1.初始化演示2.push_back()演示3.insert()演示4.pop_back()演示5.erase()演示6.size()演示7.empty()演示8.assign()演示#include<iostream>#include<vector>using namespace std;typedef vector<int> vint;int main(){ cout<<"初始化对象:"<<endl; vint vec1; ///vec1对象初始为空 vint vec2(10, 6); ///vec2对象最初有 阅读全文

posted @ 2011-11-23 10:24 More study needed. 阅读(245) 评论(0) 推荐(0) 编辑

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 19 下一页

导航

书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!