当前位置:网站首页>冒泡排序 指针
冒泡排序 指针
2022-06-22 20:56:00 【holoyh】
#include<stdio.h>
#include<stdlib.h>
int main() {
int a[] = { 3,2,1,7,6 };
int n = sizeof(a) / sizeof(a[0]);
int *p ,*q;
int tmp;
int *x = a + n - 1;
for(p = a; p < a + n - 1; p++,x--) {
for (q = a; q < x; ++q) {
if (*q < *(q + 1)) {
tmp = *q;
*q = *(q + 1);
*(q + 1) = tmp;
}
}
}
for (int i = 0; i < n; ++i) {
printf("%d ", a[i]);
}
system("pause");
return 0;
}
7 6 3 2 1
边栏推荐
- Explain the startup process of opengauss multithreading architecture in detail
- MySQL master-slave synchronization and its basic process of database and table division
- [redisson] source code analysis of multilock
- Palindromes (simple version)
- ArcGIS应用(二十)Arcgis 栅格图像符号系统提示“This dataset does not have valid histogram required for classificati…”
- 使用smart-doc自动生成接口文档
- c# sqlsugar,hisql,freesql orm框架全方位性能测试对比 sqlserver 性能测试
- 获取当前所在周的起始和结束的日期
- Ensure database and cache consistency
- js----SVG转PNG
猜你喜欢

Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!

【Kubernetes 系列】Kubernetes 概述

Spark RDD Programming Guide(2.4.3)

2021-05-02

SourceTree版本管理常用操作

2021-08-21

【STM32技巧】使用STM32 HAL库的硬件I2C驱动RX8025T实时时钟芯片

Practice brings true knowledge: the strongest seckill system architecture in the whole network is decrypted. Not all seckills are seckills!!

Introduction to database access tools

'dare not doubt the code, but have to doubt the code 'a network request timeout analysis
随机推荐
Three cache methods and principles
Is it bad for NFT that the market starts to cool down?
A spark app demo
使用Redisson操作分布式队列的注意事项
Spark SQL 访问json和jdbc数据源
Grafana report display of sentinel based high availability current limiting system
Remote access and control - SSH Remote Management and TCP wrappers access control
Half optimized SQL
The mental process and understanding of visual project code design
c# sqlsugar,hisql,freesql orm框架全方位性能测试对比 sqlserver 性能测试
Talk about SQL profile again: can I fix the execution plan?
Which securities company is the safest and best choice for stock trading account opening
14. 最长公共前缀
剑指 Offer 06. 从尾到头打印链表
对 cookie 的添加/获取和删除
C language -- 17 function introduction
R language builds a binary classification model based on H2O package: using H2O GLM constructs regularized logistic regression model and uses H2O AUC value of AUC calculation model
Common operations of sourcetree version management
【22暑期复建1】 Codeforces Round #791 (Div. 2)
保证数据库和缓存的一致性