当前位置:网站首页>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
边栏推荐
- c结构体中定义的成员指针赋值与结构体指针作为成员函数参数的使用
- Sword finger offer (V): queue with two stacks
- Bash shell学习笔记(七)
- Implementing queues with two stacks
- Pengge C language - minesweeping 2021-08-16
- ESXi6.5补丁更新
- Tutorial of putty
- BLE之ATT请求
- RT thread learning notes (VII) -- open the elmfat file system based on SPI flash (middle)
- 软件测试综述之软件测试的背景、实质、软件开发的过程
猜你喜欢

Bash shell learning notes (4)

Tutorial of putty

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

Kali view IP address

232.用栈实现队列

企鹅龙(DRBL)无盘启动+再生龙(clonezilla)网络备份与还原系统

Bash shell learning notes (6)

Bash shell learning notes (VII)

LE Audio规范概述

RT thread learning notes (VI) -- start the elmfat file system based on SPI flash (Part 1)
随机推荐
企鹅龙(DRBL)无盘启动+再生龙(clonezilla)网络备份与还原系统
C#笔记
C语言命名空间的定义与使用
WinPcap packet capturing function pcap_ Loop (), stop the problem
面试过程中,面试官是如何考察Rust工程师的水平?
Bash shell learning notes (VII)
Kali view IP address
Capture ZABBIX performance monitoring chart with selenium
Stringing of macro parameters and connection of macro parameters in C language
Fragment lazy load
RT thread learning notes (V) -- edit, download and debug programs
Basic use of logging
很多人都不清楚自己找的是Kanban软件还是看板软件
logging 高级使用
Simple use of MFC multithreading
1748.唯一元素的和
Happens-Before原则深入解读
Bash shell学习笔记(三)
Bash shell学习笔记(一)
智能合约dapp系统开发流程技术