当前位置:网站首页>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
边栏推荐
- Traversal recursion + iteration of binary tree
- Bash shell学习笔记(四)
- 企鹅龙(DRBL)无盘启动+再生龙(clonezilla)网络备份与还原系统
- During the interview, how did the interviewer evaluate the level of rust engineers?
- MultipartFil转为File
- 菜鸟看源码之HashTable
- Bash shell learning notes (II)
- -bash: ./build. Sh: /bin/bash^m: bad interpreter: no that file or directory
- 35. Search the insertion position
- Pre post pytest method
猜你喜欢

RT thread learning notes (VII) -- open the elmfat file system based on SPI flash (middle)

母亲

20210807 1 c language program structure

pytest 执行规则_基本用法_常用插件_常用断言_常用参数

Pytest execution rules_ Basic usage_ Common plug-ins_ Common assertions_ Common parameters

Wireshark basic tutorial Ethernet frame analysis.

Esxi6.5 patch update

看源码之LinkedList

nmap弱点扫描结果可视化转换

pytest 前后置方法
随机推荐
A method to deal with the crash of C Halcon user control
企鹅龙(DRBL)无盘启动+再生龙(clonezilla)网络备份与还原系统
Why do I need automated testing? Software testers take you to evaluate different software testing tools
Solve the problem of the popularity of org.apache.commons.codec.binary.base64
Fragment lazy load
面试知识点
Simple use of MFC multithreading
pytest 执行规则_基本用法_常用插件_常用断言_常用参数
微信公众号开发 获取openid时报错40029 invalid code 问题的解决
Sword finger offer (8): jump the steps
菜鸟看源码之LinkedBlockingQueue
Interview knowledge points
MFC多线程的简单使用
为什么需要自动化测试?软件测试师带你测评不同软件测试工具
PLC与伺服电机连接
ThreadPoolExecutor是怎样执行任务的
pytest 前后置方法
Bash shell learning notes (II)
如何组装一个注册中心?
智能合约dapp系统开发流程技术