stringstream的大用处
AC代码:
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
using namespace std;
const int maxn = 1000;
int a[maxn];
int main()
{
string line;
while (cin >> line)
{
for (int i = 0; i < line.length(); i++)
{
if (line[i] == '5')
line[i] = ' ';
}
int n = 0, x;
stringstream ss(line);
while (ss >> x)
a[n++] = x;
sort(a, a + n);
printf("%d", a[0]);
for (int i = 1; i < n; i++)
printf(" %d", a[i]);
printf("\n");
}
// system("pause");
return 0;
}