标签:hdu1106
0051231232050775
0 77 12312320
#include <iostream> #include <string> #include <algorithm> using std::endl; using std::cin; using std::cout; using std::string; using std::sort; const int MAXN = 1000; int num[MAXN]; int strtoint(string s) { int n=0; for(int i=0; i<s.length(); ++i) { n = n*10 + (s[i]-'0'); } return n; } int main() { #ifdef LOCAL freopen("input.txt" , "r" , stdin); #endif string str; while(cin >> str) { int m = 0; string intStr; intStr.clear(); for(int i=0; i<str.length(); ++i) { if(str[i] == '5') { if(intStr.length()>0) { num[m++] = strtoint(intStr); } intStr.clear(); }else if(i == str.length()-1){ intStr += str[i]; num[m++] = strtoint(intStr); }else{ intStr += str[i]; } } sort(num , num+m); for(int i=0; i<m; ++i) { cout << num[i]; if(i!=m-1) { cout << " "; }else{ cout << endl; } } } return 0; }
标签:hdu1106
原文地址:http://blog.csdn.net/computer_liuyun/article/details/29594097