返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<sstream>
  4. using namespace std;
  5. int main()
  6. {
  7. string str="123.45.6789.111213";
  8. str+=".";
  9. string res[50];
  10. string tmp="";
  11. int index=0;
  12. for(int i=0;i<str.size();i++)
  13. {
  14.     if(str[i]=='.')
  15.     {
  16.        res[index]=tmp;
  17.        tmp="";
  18.        index++;            
  19.     }else
  20.     {
  21.         tmp+=str[i] ;
  22.     }   
  23. }
  24.      for(int i=0;res[i]!="";i++)
  25.      {
  26.          cout<<res[i]<<endl;   
  27.      }
  28.    system("pause");
  29.    return 0;
  30. }
複製代碼

TOP

返回列表