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