zoukankan      html  css  js  c++  java
  • sort-插入排序

    void sort_insertion(vector<int> &v)
    {
    	for(int i=1;i<v.size();i++)
    	{
    		for(int j=i;j>0;j--)
    		{
    			if(v[j]<v[j-1])
    			{
    				int tmp=v[j-1];
    				v[j-1]=v[j];
    				v[j]=tmp;
    			}
    			else
    				break;
    		}
    	}
    
    }
    
  • 相关阅读:
    11.29
    11.28
    11.24
    11.21
    11.17
    11.15
    11.14
    11.9
    11.5
    11.3
  • 原文地址:https://www.cnblogs.com/smallredness/p/10683705.html
Copyright © 2011-2022 走看看