冒泡排序

ASP.net 孤独木木 8年前 (2016-08-01) 4905次浏览 已收录 0个评论 扫描二维码
 public string GetInt()
    {
        int[] a = { 9, 5, 10, 10, 20, 88, 100 };
        for(int i = 0; i < a.Length; i++)
        {
            for(int j = i + 1; j < a.Length; j++)
            {
                if (a[i] > a[j])
                {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }              
            }
        }
        string s = "";
        foreach (int item in a)
        {
            s += item+",";
        }
        return s;
    }
喜欢 (1)
[15390816981]
分享 (0)

您必须 登录 才能发表评论!