博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1.把一个字符串内的正整数相加
阅读量:7105 次
发布时间:2019-06-28

本文共 655 字,大约阅读时间需要 2 分钟。

1 #include "string" 2 typedef std::basic_string
tstring; 3 int _tmain(int argc, _TCHAR* argv[]) 4 { 5 6 tstring str= _T("没2有60最脑40残只有100更脑残!5"); 7 const tstring numSet = _T("0123456789"); 8 tstring::size_type pos = str.find_first_of(numSet); 9 int iFinal(0);10 while (str.npos != pos){11 tstring::size_type pos2 = str.find_first_not_of(numSet, pos);12 tstring strNum = str.substr(pos, pos2 - pos);13 int iNum = _ttoi(strNum.c_str());14 iFinal += iNum;15 pos = str.find_first_of(numSet, pos2);16 }17 18 return 0;19 }

 

转载于:https://www.cnblogs.com/ezhong/p/3973226.html

你可能感兴趣的文章
王垠:怎样写一个解释器
查看>>
解决unicodedecodeerror ascii codec can’t decode byte 0xd7 in position 9 ordinal not in range(128)...
查看>>
Redis和Memcached的区别
查看>>
Mysql 5.7.20 源码安装笔记
查看>>
CSS选择器种类及介绍
查看>>
struts2 + form 表单上传文件
查看>>
探索网络安全管理
查看>>
dedecms 模板中解析php代码
查看>>
Mysql数据库的安全配置、实用技巧
查看>>
UML用例图
查看>>
raid原理及软raid实现
查看>>
PHP每天学一点
查看>>
tar命令
查看>>
面向对象与原型
查看>>
KVM使用QCOW2创建虚拟机报不支持错误
查看>>
解决Linux和SecureCRT上UTF-8汉字乱码问题
查看>>
教程-转 十大OpenGL教程
查看>>
Windows系统下的TCP参数优化
查看>>
UbuntuServer10.10下安装OpenWebAnalytics (1)
查看>>
freemarker对java null的处理技巧总结
查看>>