1. 首页
  2. 编程语言
  3. C
  4. 更新排序方法的.xaml.cs文件

更新排序方法的.xaml.cs文件

上传者: 2023-03-10 06:18:33上传 CS文件 6.2KB 热度 10次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sort
{
    public class UpdateSort
    {
        // 更新排序方法,可以实现更加精准的排序功能
        public void Update(List<int> list)
        {
            int temp;
            for (int i = 0; i < list.Count; i++)
            {
                for (int j = 0; j < list.Count - i - 1; j++)
                {
                    if (list[j] > list[j + 1])
                    {
                        temp = list[j];
                        list[j] = list[j + 1];
                        list[j + 1] = temp;
                    }
                }
            }
        }
    }
} 

下载地址
用户评论