当前位置:网站首页>C语言中的排序,实现从小到大的数字排序法
C语言中的排序,实现从小到大的数字排序法
2022-07-04 06:19:00 【喜欢吃火锅的泪】
摘要:对于项目开发,有时候想要对一个ADC采集的电压进行排序,然后得出稳定的ADC值,则需要对排序是必不可少的。
get_value[10] = {23,10,9,75,22,33,0,8,6,20};
int main(void)
{
for (uint8_t i = 1; i < 10; i ++)
{
for (uint8_t j = 0; j < 10 - i; j ++)
{
if (get_value[j] > get_value[j + 1])
{
tmp = get_value[j];
get_value[j] = get_value[j + 1];
get_value[j + 1] = tmp;
}
}
}for(uint8_t i = 0;i<10;i++)
{
printf("get_value[%d] = %d ,",i,get_value[i]);
}
}
结果:
0,6,8,9,10,20,22,23,33,75,
边栏推荐
- Manually page the list (parameter list, current page, page size)
- 如何判断数组中是否含有某个元素
- Sort list tool class, which can sort strings
- Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
- Luogu deep foundation part 1 Introduction to language Chapter 5 array and data batch storage
- 27-31. Dependency transitivity, principle
- 如何获取el-tree中所有节点的父节点
- 测试岗的中年危机该如何选择?是坚守还是另寻出路?且看下文
- gslb(global server load balance)技术的一点理解
- SQL join, left join, right join usage
猜你喜欢
509. Fibonacci number, all paths of climbing stairs, minimum cost of climbing stairs
Bicolor case
Reading notes of Clickhouse principle analysis and Application Practice (4)
SQL injection SQL lab 11~22
Tf/pytorch/cafe-cv/nlp/ audio - practical demonstration of full ecosystem CPU deployment - Intel openvino tool suite course summary (Part 2)
实用的小工具指令
报错cvc-complex-type.2.4.a: 发现了以元素 ‘base-extension‘ 开头的无效内容。应以 ‘{layoutlib}‘ 之一开头。
A little understanding of GSLB (global server load balance) technology
Arcpy uses the updatelayer function to change the symbol system of the layer
gslb(global server load balance)技术的一点理解
随机推荐
每周小结(*63):关于正能量
How to avoid JVM memory leakage?
Vant --- detailed explanation and use of list component in vant
el-select如何实现懒加载(带搜索功能)
STC8H开发(十二): I2C驱动AT24C08,AT24C32系列EEPROM存储
win10清除快速访问-不留下痕迹
px em rem的区别
Json Web token - jwt vs. Traditional session login Authentication
Component、Container容器常用API详解:Frame、Panel、ScrollPane
How to solve the component conflicts caused by scrollbars in GridView
17-18. Dependency scope and life cycle plug-ins
【微服务】Nacos集群搭建以及加载文件配置
"In simple language programming competition (basic)" part 1 Introduction to language Chapter 3 branch structure programming
Sword finger offer II 038 Daily temperature
2022.7.2-----leetcode. eight hundred and seventy-one
Nexus 6p从8.0降级6.0+root
Notes and notes
Abap:ooalv realizes the function of adding, deleting, modifying and checking
Learning multi-level structural information for small organ segmentation
AWT introduction