当前位置:网站首页>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,
边栏推荐
- 对List进行排序工具类,可以对字符串排序
- MySQL的information_schema数据库
- 【微服务】Nacos集群搭建以及加载文件配置
- FRP intranet penetration, reverse proxy
- High performance parallel programming and optimization | lesson 02 homework at home
- QT qtablewidget table column top requirements ideas and codes
- C realize Snake games
- Weekly summary (*63): about positive energy
- 509. Fibonacci number, all paths of climbing stairs, minimum cost of climbing stairs
- 剑指 Offer II 038. 每日温度
猜你喜欢
win10清除快速访问-不留下痕迹
配置交叉编译工具链和环境变量
JSON web token -- comparison between JWT and traditional session login authentication
740. Delete and get points
198. House raiding
云原生——上云必读之SSH篇(常用于远程登录云服务器)
[openvino+paddle] paddle detection / OCR / SEG export based on paddle2onnx
JS arguments parameter usage and explanation
【微服务】Nacos集群搭建以及加载文件配置
我的NVIDIA开发者之旅——优化显卡性能
随机推荐
Design and implementation of tcp/ip series overview
Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane
Internet of things protocol ZigBee ZigBee module uses the concept of protocol stack
How to implement lazy loading in El select (with search function)
buuctf-pwn write-ups (8)
Gridview出现滚动条,组件冲突,如何解决
AWT introduction
如何实现视频平台会员多账号登录
How does apscheduler set tasks not to be concurrent (that is, execute the next task after the first one)?
C實現貪吃蛇小遊戲
ABAP:OOALV实现增删改查功能
FRP intranet penetration, reverse proxy
Uninstall Google drive hard drive - you must exit the program to uninstall
STC8H开发(十二): I2C驱动AT24C08,AT24C32系列EEPROM存储
js如何将秒转换成时分秒显示
每周小结(*63):关于正能量
My NVIDIA developer journey - optimizing graphics card performance
How to solve the component conflicts caused by scrollbars in GridView
el-select如何实现懒加载(带搜索功能)
How to avoid JVM memory leakage?