- #include<iostream>
- #include<cstdlib>
- #include<string>
- using namespace std;
- int main()
- {
- string str="123.45.6789";
- str +=".";
- string pig[10];
- int index=0;
-
- string tmp="";
- for(int i=0;i<str.size();i++)
- {
- if(str[i] == '.')
- {
- pig[index] = tmp;
- tmp = "";
- index++;
- }
- else
- {
- tmp += str[i];
- }
- }
-
- for(int i=0;pig[i]!=""; i++)
- cout<<pig[i]<<endl;
- system("pause");
- return 0;
- }
複製代碼 |