#include
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
/* //法1,使用find函数
string st="1001,88.67,1003,22.1,1002,76.3";
int pos_st=0;
pos_st=st.find(",");
if(pos_st<0)//判空
{
cout<<"letter not exist"<*/
//法2,类似快慢指针
int slow(0),fast(0);
string st2="1001,88.67,1003,22.1,1002,76.3";
while(fast<st2.size())
{
if(st2[fast]==',')//相等保留逗号位置
{
string res=st2.substr(slow,fast-slow);//取到逗号为止的内容
cout<endl;
fast=fast+1;//跳过当前逗号
slow=fast;//从逗号的后一个开始找下一个逗号
}
++fast;
}
if(st2[st2.size()-1]!=',')//字符串最后是否为逗号
{
cout<slow);
}
return 0;
}