返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  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.    
  12.     string tmp="";
  13.     for(int i=0;i<str.size();i++)
  14.     {
  15.         if(str[i] == '.')
  16.         {
  17.             pig[index] = tmp;      
  18.             tmp = "";      
  19.             index++;
  20.         }
  21.         else
  22.         {
  23.            tmp += str[i];
  24.         }              
  25.     }
  26.    
  27.     for(int i=0;pig[i]!=""; i++)
  28.         cout<<pig[i]<<endl;
  29.     system("pause");
  30.     return 0;
  31. }
複製代碼

TOP

返回列表