当前位置:网站首页>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,
边栏推荐
猜你喜欢

27-31. Dependency transitivity, principle

How to avoid JVM memory leakage?

JSON web token -- comparison between JWT and traditional session login authentication

双色球案例

After the festival, a large number of people change careers. Is it still time to be 30? Listen to the experience of the past people

我的NVIDIA开发者之旅——优化显卡性能

buuctf-pwn write-ups (8)

AWT introduction

分布式CAP理论

C language - Blue Bridge Cup - Snake filling
随机推荐
Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
2022.7.3-----leetcode.556
Grounding relay dd-1/60
js获取对象中嵌套的属性值
Install pytoch geometric
Leakage detection relay jy82-2p
win10清除快速访问-不留下痕迹
MySQL learning notes 3 - JDBC
Sort list tool class, which can sort strings
Detectron: train your own data set -- convert your own data format to coco format
[untitled]
配置交叉编译工具链和环境变量
Average two numbers
JS flattened array of number shape structure
Uninstall Google drive hard drive - you must exit the program to uninstall
el-select如何实现懒加载(带搜索功能)
Impact relay jc-7/11/dc110v
Understanding of cross domain and how to solve cross domain problems
Configure cross compilation tool chain and environment variables
Steady! Huawei micro certification Huawei cloud computing service practice is stable!