代码:字符串中连续与重复字符判断
来源:互联网 发布:火箭22连胜麦迪数据 编辑:程序博客网 时间:2024/05/17 03:50
字符串操作:
int consecutiveCharMaxCount( char *str)
{
char *pstr = NULL;
char *p = NULL;
int value = 0;
int incN = 1;
int decN = 1;
int maxCount = 0;
char chrp = 0;
char chrn = 0;
if(str == NULL)
return ERROR;
p = str;
while(*p != '\0')
{
pstr = p;
incN = 1;
decN =1;
value = 0;
while(*pstr != '\0')
{
chrp = *pstr;
chrn = *(++pstr);
value = chrp - chrn;
if(value == 1)
incN++;
else
{
maxCount = (maxCount>=incN)?maxCount:incN;
incN = 1;
}
if(value == -1)
decN++;
else
{
maxCount = (maxCount>=decN)?maxCount:decN;
decN = 1;
}
}
p++;
}
return maxCount;
}
int repeatedCharMaxCount( char *str)
{
char pchar[2] = {0};
char *pindex = NULL;
char *pstr = NULL;
int n = 0;
int maxCount = 0;
if(str == NULL)
return ERROR;
pstr = str;
while(*pstr != '\0')
{
memset(pchar,0,2);
pchar[0] = *pstr;
pindex = index(pstr,pchar[0]);
n = strspn(pindex,pchar);
maxCount = (maxCount>=n)?maxCount:n;
pstr++;
}
return maxCount;
}
1 0
- 代码:字符串中连续与重复字符判断
- 判断字符串中是否有重复字符
- 赐除掉某一字符串中连续重复的字符序列
- 黑马程序员_去掉字符串中连续重复字符函数
- 判断字符串有重复字符
- 压缩字符串中的连续重复字符
- 压缩字符串中的连续重复字符
- 通过位操作判断字符串中是否存在重复字符
- 判断字符串中是否没有重复的字符
- java 判断字符串中是否有重复字符
- 从字符串S中找出不包含重复字符的最大连续子字符串长度
- 删除字符串中连续字符
- STL学习-字符串回文判断以及实现删除字符串中重复字符最少字符
- 求一个字符串中字符不重复的连续的子串
- 字符串中不重复连续字符子串的长度最大值
- 正则判断字符串包含重复字符
- 1.1-判断字符串是否有重复字符
- 如何判断字符串是否包含重复字符
- android 开发 屏幕适配 概念
- javascript 闭包
- sqlite3_finalize sqlite3_close
- 细说JavaScript面向对象编程
- [LeetCode]Divide Two Integers
- 代码:字符串中连续与重复字符判断
- android设备打印过滤log的方法
- cocos2d-x-3.3rc2-000-run-testCpp 并附apk下载
- Object-C中单例模式的实现
- Apache Mina(二)
- c语言图形显示转换为指针显示
- Android工程中jni本地调用opencv时,某些函数不识别问题
- Core Data学习
- OC反射机制