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

TOP

返回列表