输入例子:
aabcd
输出例子:
a
aa
aab
aabc
ab
abc
b
bc
bcd
c
cd
d
#include
#include
using namespace std;
void Grial(char *str)
{
int n = strlen(str);
while(*str!='\0')
{
for(int i = 1;i<=n...
分类:
编程语言 时间:
2015-04-29 00:50:13
阅读次数:
598
一、sizeof sizeof(...)是运算符,在头文件中typedef为unsigned int,其值在编译时即计算好了,参数可以是数组、指针、类型、对象、函数等。 它的功能是:获得保证能容纳实现所建立的最大对象的字节大小。 由于在编译时计算,因此sizeof不能用来返回动态分配的内存空间的大小...
分类:
其他好文 时间:
2015-04-28 22:15:22
阅读次数:
170
char str[1000010],pat[1000010];//pat为模式串,str为主串
int Next[1000010]; //Next[x]下标x表示匹配失败处字符下标
//模式串pat的前缀与x位置的后缀的最大匹配字符个数-1
void GetNext(char *pat)
{
int LenPat = strlen(pat);
int i = 0,j = -1;
...
分类:
其他好文 时间:
2015-04-28 21:10:30
阅读次数:
143
题目:
给定两个字符串s1和s2,要求判定s2是否能够被s1做循环移位得到的字符串包含。
解法一:O(N^2)
对s1进行循环移位,在进行字符串包含的判断。
//s1,s2
int len = strlen(s1);
for(i:len)
{
char t=s1[0];
for(j:len-1)
s1[j]=s[j+1];
s1[len...
分类:
其他好文 时间:
2015-04-28 14:14:18
阅读次数:
122
虽然是水题,一开始也错了好多次,真是坑啊!
#include
using namespace std;
char a[101];
char c[26];
bool index[26];
void create()
{
int i,j;
memset(index,0,sizeof(index));
for(i=0;i<strlen(a);i++)
...
分类:
Web程序 时间:
2015-04-26 22:55:08
阅读次数:
172
strlen() --> 返回字符串的长度 以ox00结束sizeof() --> 返回分配的内存大小char str[10]="123"; //字符串占四个字节int a=strlen(str); //a=3; 不包括结束符int b=sizeof(str); //b=10; 表示数组大小
分类:
其他好文 时间:
2015-04-26 22:44:54
阅读次数:
127
#include
#define STRLEN 100
int Is_palindromic_str(char *str)
{
int left = 0;//字符串数组的第一个字母的下标
int i = 0;
while(str[i] != '\0')
{
i++;
}
int right = i - 1;//字符串数组最后一个字母(非‘\0’)的下标
while(left <...
分类:
其他好文 时间:
2015-04-26 19:48:54
阅读次数:
351
#include "stdafx.h"
#include #include using namespace std; class MyString
{
private: char *str;
public: MyString(char *s) { str=new char[strlen(s)+1];...
分类:
其他好文 时间:
2015-04-26 18:20:02
阅读次数:
108
//strcat(dest,src)把src所指字符串添加到dest结尾处(覆盖dest结尾处的'\0')并添加'\0'char *strcat(char * strDest, const char *strSrc){ char *res=strDest; assert((strDest...
分类:
编程语言 时间:
2015-04-26 16:40:28
阅读次数:
227
//将字符串反转,型如:123 456 789 abc ,反转后的结果是 abc 789 456 123
/*
#include
#include
using namespace std;
void Exchange(char *&str)
{
char *p=str+strlen(str)-1;
char *q=str;
while(q<p)
{
char temp=*q;
...
分类:
编程语言 时间:
2015-04-26 10:57:59
阅读次数:
181