当前位置:网站首页>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,
边栏推荐
- Nexus 6p从8.0降级6.0+root
- 剑指 Offer II 038. 每日温度
- 740. Delete and get points
- Appium基础 — APPium安装(二)
- C réaliser des jeux de serpents gourmands
- 云原生——上云必读之SSH篇(常用于远程登录云服务器)
- 【无标题】
- LayoutManager布局管理器:FlowLayout、BorderLayout、GridLayout、GridBagLayout、CardLayout、BoxLayout
- Leetcode question brushing record | 206_ Reverse linked list
- AWT common components, FileDialog file selection box
猜你喜欢

Sleep quality today 78 points
![[openvino+paddle] paddle detection / OCR / SEG export based on paddle2onnx](/img/a9/72791cbcc6c9da45e89450ab2820c1.jpg)
[openvino+paddle] paddle detection / OCR / SEG export based on paddle2onnx

Learn about the Internet of things protocol WiFi ZigBee Bluetooth, etc. --- WiFi and WiFi protocols start from WiFi. What do we need to know about WiFi protocol itself?

Detectron:训练自己的数据集——将自己的数据格式转换成COCO格式

C realize Snake games

树形dp

Learning multi-level structural information for small organ segmentation

如何实现视频平台会员多账号登录

Reading notes of Clickhouse principle analysis and Application Practice (4)

QT QTableWidget 表格列置顶需求的思路和代码
随机推荐
70000 words of detailed explanation of the whole process of pad openvino [CPU] - from environment configuration to model deployment
MySQL learning notes 3 - JDBC
Gridview出现滚动条,组件冲突,如何解决
buuctf-pwn write-ups (8)
Cloud native - SSH article that must be read on the cloud (commonly used for remote login to ECS)
Kubernets first meeting
Average two numbers
JSON Web Token----JWT和傳統session登錄認證對比
JSON web token -- comparison between JWT and traditional session login authentication
Sort list tool class, which can sort strings
Appium基础 — APPium安装(二)
746. Climb stairs with minimum cost
Weekly summary (*63): about positive energy
Design and implementation of redis 7.0 multi part AOF
509. Fibonacci number, all paths of climbing stairs, minimum cost of climbing stairs
Arcpy 利用updatelayer函数改变图层的符号系统
Detectron: train your own data set -- convert your own data format to coco format
报错cvc-complex-type.2.4.a: 发现了以元素 ‘base-extension‘ 开头的无效内容。应以 ‘{layoutlib}‘ 之一开头。
对List进行排序工具类,可以对字符串排序
Qt发布多语言国际化翻译