zoukankan      html  css  js  c++  java
  • hdoj-1106-排序(stringstream)

    题目链接

     1 /*
     2     Name:
     3     Copyright:
     4     Author:
     5     Date: 2018/5/2 20:56:53
     6     Description:
     7 */
     8 #include <iostream>
     9 #include <cstdio>
    10 #include <cstring>
    11 #include <algorithm>
    12 #include <sstream>
    13 #include <vector>
    14 using namespace std;
    15 int arr[30];
    16 int main()
    17 {
    18     string str;
    19     while (cin>>str) {
    20         int i = 0;
    21         while (str[i] == '0') i++;
    22         if (i > 1) str = str.substr(i-1);
    23         int pos = 0;
    24         while ( (pos = str.find('5')) != -1) {
    25             str.replace(pos, 1, " ");
    26         }
    27         stringstream ss;
    28         ss<<str;
    29         vector<int> vec;
    30         while (ss>>i) vec.push_back(i);
    31         sort(vec.begin(), vec.end());
    32         cout<<vec[0];
    33         for (int i=1; i<vec.size(); i++) {
    34             cout<<" "<<vec[i];
    35         }
    36         cout<<endl;
    37     }
    38     return 0;
    39 }
  • 相关阅读:
    [译]git reflog
    [译]git rebase -i
    [译]git rebase
    [译]git commit --amend
    [译]git clean
    [译]git reset
    [译]git revert
    [译]git checkout
    [译]git log
    [译]git status
  • 原文地址:https://www.cnblogs.com/langyao/p/8982592.html
Copyright © 2011-2022 走看看