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

TOP

返回列表