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

TOP

返回列表