fork download
  1. /* Author haleyk10198 */
  2. /* 作者: haleyk10198 */
  3. #include <bits/stdc++.h>
  4.  
  5. #define MOD 1000000007
  6. #define LINF (1LL<<60)
  7. #define INF 2147483647
  8. #define PI 3.1415926535897932384626433
  9. #define ll long long
  10. #define pii pair<int,int>
  11. #define mp(x,y) make_pair((x),(y))
  12.  
  13. using namespace std;
  14.  
  15. string itos(int x){
  16. stringstream ss;
  17. ss<<x;
  18. return ss.str();
  19. }
  20.  
  21. const string numeric = "1234567890.";
  22.  
  23. int main(){
  24. //freopen("input.txt","r",stdin);
  25. //freopen("output.txt","w",stdout);
  26. //ios_base::sync_with_stdio(false);
  27. string str;
  28. while(getline(cin, str, '\n')){
  29. int pos = 0, nxt;
  30. vector<float> v;
  31. while(true){
  32. nxt = str.find_first_not_of(numeric, pos);
  33. if(nxt == string::npos)
  34. nxt = str.length();
  35. v.push_back(stof(str.substr(pos, nxt - pos)));
  36. if(nxt == str.length())
  37. break;
  38. pos = str.find_first_of(numeric, nxt);
  39. if(pos == string::npos)
  40. break;
  41. }
  42. for(int i = 0 ; i < v.size(); i++)
  43. cout << v[i] << (i+1 == v.size()? '\n': ' ');
  44. }
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0s 3476KB
stdin
12csac54d46dvs15.2scas 
1.23a2.222bbb33.33dd444.4ggg55gg77.7
stdout
12 54 46 15.2
1.23 2.222 33.33 444.4 55 77.7