后缀数组水题
先求所有的子串数,根据长度枚举,共(n+1)*n/2种
当height[i]>0时,说明height[i]这个前缀与其他子串相同,减去这height[i]个子串
#include
#include
#include
using namespace std;
#define N 1005
int r[N],sa[N],height[N],rank[N],wa[N],wb[N],w...
分类:
其他好文 时间:
2015-04-14 09:59:40
阅读次数:
125
有n个重量和价值分别为wi 和 vi 的 物品,从这些物品中选择总重量不超过 W的物品,求所有挑选方案中物品价值总和的最大值。 1 2 #include 3 #include 4 #include 5 using namespace std; 6 const int MAX = 0x3fffff.....
分类:
其他好文 时间:
2015-04-14 09:52:53
阅读次数:
112
实现字符串strstr()的功能,即从母串中查找子串第一次出现的位置(序号),没有出现则返回-1.【思路】刚开始学c时就学到过这个例子。不同之处在于,这里参数是string,处理起来要比char*简单。【my code】int strStr(string haystack, string needl...
分类:
其他好文 时间:
2015-04-14 09:51:37
阅读次数:
121
1 #include 2 #include 3 4 #define PAGELEN 24 5 #define LINELEN 512 6 7 int see_more(FILE*); 8 void do_more(FILE*); 9 10 int main(int ac, ch...
分类:
其他好文 时间:
2015-04-14 09:46:42
阅读次数:
145
黑马程序员 第十天笔记 java培训1.接口定义关键字 interface 接口名{成员变量:Public static final int I=10;成员方法:Public abstract 返回值类型 方法名(参数);}接口的权限必须最大public,不写权限,编译的时...
分类:
其他好文 时间:
2015-04-14 09:45:41
阅读次数:
118
解题思路:1、将字符串转置2、对转置后的字符串中单词转置 1 #include 2 #include 3 #include 4 #include 5 //字符串转置 6 void tranStr(const char *p,char *s) 7 { 8 int len = strlen(p)...
分类:
其他好文 时间:
2015-04-14 09:44:48
阅读次数:
133
#include "stdafx.h"#include #include typedef struct stack{int data;struct stack *next;}STACK;STACK *head,*pr;int nodeNum = 0;STACK *Createnote(int num...
分类:
其他好文 时间:
2015-04-14 09:42:33
阅读次数:
135
//作业2. 1-2
template
void insert(T* A, int n)
{
for (int j = 1; j
{
T key = A[j];
int i = j - 1;
while (i >= 0 && key > A[i])
{
A[i + 1] = A[i];
--i;
}
A[i + 1] = key;
}
}
//2. 1-...
分类:
编程语言 时间:
2015-04-14 08:37:14
阅读次数:
163
C++类中成员变量的初始化有两种方式:
构造函数初始化列表和构造函数体内赋值
1 内部数据类型(char,int……指针等)
class Animal{public: Animal(int weight,int height): //A初始化列表 m_weight(weight), m_height(height) { }...
分类:
编程语言 时间:
2015-04-14 08:35:44
阅读次数:
161
#include
#include
#include
using namespace std;
int n,m;
struct e
{
char a[200];
int id;
int px;
}s[200];
int cmp(e s1,e s2)
{
if(s1.px==s2.px) return s1.id<s2.id;
else return s1....
分类:
其他好文 时间:
2015-04-14 08:35:35
阅读次数:
171