#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
vector<int> hand;
int n;
while(cin>>n)
{
hand.push_back(n);
for(vector<int>::size_type j = 1; j < hand.size(); j++)
{
if(hand[j-1] > hand[hand.size()-1])
{
for(vector<int>::size_type i = hand.size() - 1; i > j - 1; i--)
{
hand[i] = hand[i - 1];
}
hand[j-1] = n;
}
}
}
for(vector<int>::size_type x = 0; x < hand.size(); x++)
{
cout<<hand[x]<<" ";
}
}
插入排序
最新推荐文章于 2022-04-28 23:03:58 发布