求最大连续递增数字串(如"ads3sl456789DF3456ld345AA"中的"456789")
int GetSubString(char *strSource, char *strResult) {
int iTmp=0, iHead=0, iMax=0;
for(int Index=0, iLen=0; strSource[Index]; Index++) {
if(strSource[Index] >= ’0′ && strSource[Index] ’0′ && strSource[Index] == strSource[Index-1]+1) {
iLen++; // 连续数字的长度增1
} else { // 出现字符或不连续数字
if(iLen > iMax) {
iMax = iLen; iHead = iTmp;
}
// 该字符是数字,但数字不连续
if(strSource[Index] >= ’0′ && strSource[Index]
int iTmp=0, iHead=0, iMax=0;
for(int Index=0, iLen=0; strSource[Index]; Index++) {
if(strSource[Index] >= ’0′ && strSource[Index] ’0′ && strSource[Index] == strSource[Index-1]+1) {
iLen++; // 连续数字的长度增1
} else { // 出现字符或不连续数字
if(iLen > iMax) {
iMax = iLen; iHead = iTmp;
}
// 该字符是数字,但数字不连续
if(strSource[Index] >= ’0′ && strSource[Index]
【求最大连续递增数字串(如"ads3sl456789DF3456ld345AA"中的"456789")】相关文章
1. 求最大连续递增数字串(如"ads3sl456789DF3456ld345AA"中的"456789")
2. 解释DataSet(ds) 和 ds as DataSet 的含义
3. 请用Python写一个获取用户输入数字,并根据数字大小输出不同信息的脚本
7. 递归实现回文判断(如:abcdedbca就是回文,判断一个面试者对递归理解的简单程序)
本文来源:https://www.mianshiwenti.com/a13215.html
进入下载页面
上一篇:华为C++笔试题
下一篇:随机分配座位,共50个学生,使学号相邻的同学座位不能相邻