当前位置:网站首页>List ascending and descending
List ascending and descending
2022-07-26 10:58:00 【Lovey_ Beihe】
Ascending
sort
list.sort Sort the array in ascending order
num.Sort();
for (int i = 0; i < k; i++)
{
result.Add(num[i]);
}
Descending
sort
list.sort The array is sorted in ascending order
Flip traversal
num.Sort();
for (int i = k; i > 0; i--)
{
result.Add(num[i]);
}
The above is the use of sort Conduct , The trouble of the following method is to sort The method is disassembled into specific code
Bubble sort
for (int i = 0; i < arr.Length; i++)
{
for (int j = i; j < arr.Length; j++)
{
if (arr[i] > arr[j])
{
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
Sort from small to large
边栏推荐
猜你喜欢

为什么需要自动化测试?软件测试师带你测评不同软件测试工具

RT thread learning notes (V) -- edit, download and debug programs

pytest conftest.py和fixture的配合使用

Bash shell学习笔记(六)

Bash shell学习笔记(五)

Visual conversion of nmap vulnerability scanning results

Bash shell学习笔记(三)

20210807 1 c language program structure

Newbie sees the source code arraydeque

@NotBlank、@NotNull 、@NotEmpty 区别和使用
随机推荐
Bash shell learning notes (I)
pytest pytest.ini配置 用例分组 用例跳过
Bash shell learning notes (II)
用两个栈实现队列
微信公众号消息通知 “errcode“:40164,“errmsg“:“invalid ip
pytest 执行规则_基本用法_常用插件_常用断言_常用参数
A method to deal with the crash of C Halcon user control
菜鸟看源码之SparseArray
1748.唯一元素的和
344. Reverse string
HCI 接口
Pytest case execution sequence
MultipartFil转为File
1837.K进制表示下的各位数字总和
LE Audio规范概述
为什么需要自动化测试?软件测试师带你测评不同软件测试工具
pytest pytest. Ini configuration case grouping case skipping
Sql Server 之SQL语句对基本表及其中的数据的创建和修改
Disable usbjatg in Altium Designer
MFC中0x003b66c3 处有未经处理的异常: 0xC000041D: 用户回调期间遇到未经处理的异常