写一个函数找出连续最长的数字串
来源:互联网 发布:12月份php好找工作吗 编辑:程序博客网 时间:2024/06/07 02:24
简单题。。
1 #include <iostream> 2 using namespace std; 3 int continueNum( char *str, char *intput ) 4 { 5 int n = 0, maxcount = 0, count = 0; 6 char *p = str, *maxp = NULL, *indexp = NULL; 7 while( *p != '\0' ) 8 { 9 if( *p >= '0' && *p <= '9' ) 10 { 11 if( count++ == 0)indexp = p; 12 if(count > maxcount) 13 { 14 maxp = indexp; 15 maxcount = count; 16 } 17 } 18 else 19 { 20 count = 0; 21 } 22 23 p++; 24 } 25 n = maxcount; 26 while( n-- ) 27 { 28 *intput++ = *maxp++; 29 30 } 31 return maxcount; 32 } 33 int main() 34 { 35 char str[100] = "345as3456ty78"; 36 char intput[100] = {0}; 37 cout <<continueNum(str,intput) << endl; 38 cout << intput << endl; 39 return 0; 40 }
0 0
- 写一个函数找出连续最长的数字串
- 找出最长的连续数字串
- 在字符串中找出连续最长的数字串
- 在字符串中找出连续最长的数字串
- 25、在字符串中找出连续最长的数字串
- 在字符串中找出连续最长的数字串
- 字符串中找出连续最长的数字串
- 在字符串中找出连续最长的数字串
- 在字符串中找出连续最长的数字串
- 在字符串中找出连续最长的数字串(25)
- 在字符串中找出连续最长的数字串
- 字符串中找出连续最长的数字串
- 25. 在字符串中找出连续最长的数字串
- 在字符串中找出连续最长的数字串
- 在字符串中找出连续最长的数字串
- 在字符串中找出连续最长的数字串
- 在字符串中找出连续最长的数字串
- 在字符串中找出连续最长的数字串
- ZooKeeper应用场景-配置管理
- UVa 11997 K Smallest Sums
- C/C++库函数: 将字符串转换成小写strlwr/大写strupr(我很少用, 所以记录一下)
- Android如何在http头信息里设置参数
- 【深入浅出IOS开发】UITabBarController和UINavigationController混合使用
- 写一个函数找出连续最长的数字串
- [机器学习手记12]机器学习小思考
- Spring MVC的多视图解析器配置及与Freemarker的集成
- 如何锁定Excel中的部分单元格
- Lua基础学习开篇——类型和运算符
- 使用Memcached、Spring AOP构建数据库前端缓存框架
- SDUT14级队员训练1 G - DNA Consensus String
- 【cocos2dx网络游戏】搭建CS架构的基本通信框架(二)Sever(构建消息体)
- eclipse Freemarker插件