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

TOP

返回列表