Commando War题意:求士兵完成任务的最短时间#include #include #include using namespace std;#define N 1008struct Node{ int a; int b;}Susake[N];int comp(Node x, No...
分类:
其他好文 时间:
2014-07-15 09:33:25
阅读次数:
198
联通块是指给定n个点,输入a,b(1#includeusing namespace std;const int maxn=1010;int p[maxn];//作为每个独立的点 int sum[maxn];//每个节点下面连接的点 int find(int x) {if(x==p[x])return...
分类:
移动开发 时间:
2014-07-14 22:21:30
阅读次数:
403
曾在工作中遇见一个特别问题,就是在使用fstream中getline方法读数据读不出。如下: 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 int _tmain(int argc, _TC...
分类:
编程语言 时间:
2014-07-14 15:16:23
阅读次数:
184
部分函数已验证是正确的,还没有完全验证所有的函数有没有写正确 1 #include 2 using namespace std; 3 4 const double eps = 1e-10; 5 int dcmp(double x){//等于0 0;大于0 1;小于0 -1 6 ...
分类:
其他好文 时间:
2014-07-14 14:30:15
阅读次数:
180
区间动规主要有两种方法:
一、是先想出递归式,然后将之转化为滚动数组。
二、或者从小区间贪到大区间。
POJ 1159 点击打开链接
AC代码如下:
#include
#include
#include
using namespace std;
char a[5005];
short dp[5005][5005];
int min(int a,int b)
{
retu...
分类:
其他好文 时间:
2014-07-14 14:01:43
阅读次数:
187
考查代码能力的题目。也可以说是算法水题,呵呵。
推荐新手练习代码能力。
要增加难度就使用纯C实现一下stack,那么就有点难度了,可以使用数组模拟环形栈。做多了,我就直接使用STL了。
#include
#include
#include
#include
using namespace std;
int main()
{
stack forward;
stack ba...
分类:
Web程序 时间:
2014-07-14 13:44:44
阅读次数:
149
经验:可在derived class templates 内通过 "this->" 指涉 base class templates 内的成员名称,或藉由一个明白写出的 "base class 资格修饰符"完成。
示例:
class CompanyA{
public:
//...
void sendCleartext(const std::string &msg);
void sendEncrypted(const std::string &msg);
//...
};
class Company...
分类:
编程语言 时间:
2014-07-14 13:20:25
阅读次数:
263
#include
#include
#include
using namespace std;
#define inf 0x7ffffff
struct Edge
{
int u,v,cost;
}edge[2000];
int pre[200];//父亲
int dis[200];//到源点的距离
int n,m,src;//点的个数,边数,源点
bool relax(int...
分类:
其他好文 时间:
2014-07-14 12:59:28
阅读次数:
265
点击打开链接
题意:有n条村落连接线路,给你m个草儿附近的村落,在给出t个草儿想去的地方。从草儿附近的村落出发到她想去的地方所有线路中的花费时间最少的一个。
解析:多源多点最短路,暴力枚举
#include
#include
#include
using namespace std;
const int maxn = 1005;
const int Max = 0xfffffff;
i...
分类:
其他好文 时间:
2014-07-14 12:57:00
阅读次数:
214
以面向对象的思想和简单工厂模式,写一个C++计算器程序,代码如下:
#include
using namespace std;
class Operation {
public:
Operation(double left, double right)
{
lhs = left;
rhs = right;
}
const doub...
分类:
其他好文 时间:
2014-07-13 18:01:20
阅读次数:
354