美文网首页
[Lintcode]给一组整数,按照升序排序,插入排序java实

[Lintcode]给一组整数,按照升序排序,插入排序java实

作者: 第六象限 | 来源:发表于2017-11-06 17:47 被阅读0次
public class Solution
{
    /*
     * @param A: an integer array
     * @return: 
     */
    public void sortIntegers(int[] A) 
    {
        // write your code here
        int temp;
        for(int i = 1; i < A.length; i++)
        {  
        for(int j = i; (j > 0) && (A[j] < A[j-1]); j--) 
            {  
            temp=A[j-1];
            A[j-1]=A[j];
            A[j]=temp;
            }  
         }  
    }
   
}

相关文章

网友评论

      本文标题:[Lintcode]给一组整数,按照升序排序,插入排序java实

      本文链接:https://www.haomeiwen.com/subject/xeolmxtx.html