题目:输入一行数字123 423 5645 875 18623
输出 123 423 18623
#include<iostream>
#include<string>
using std::string;
using std::cin;
using std::cout;
using std::endl;
using std::getline;
#include<vector>
using std::vector;
#include <algorithm>
string s;
int main()
{
getline(cin,s);
const char *const_p=(char *)malloc(sizeof(char)*s.length());
const_p=s.c_str();
char *p_str=(char *)malloc(sizeof(char)*s.length());
strcpy(p_str,const_p);
vector<string> strArry;
vector<int> intArry;
char *p=NULL;
p=strtok(p_str," ");
do
{
strArry.push_back(p);
string s;
s=strArry.back();
if(s.find("23")==std::string::npos)
{
strArry.pop_back();
}
else
{
intArry.push_back(atoi(p));
}
p=strtok(NULL," ");
}while(p!=NULL);
sort(intArry.begin(),intArry.end());
for(int i=0;i<intArry.size();i++)
{
cout<<intArry[i]<<" ";
}
system("pause");
return 0;
}