当前位置:网站首页>Bubble sort pointer
Bubble sort pointer
2022-06-22 23:21: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
边栏推荐
猜你喜欢

Enjoy high-performance computing! Here comes the Tianyi cloud HPC solution

ArcGIS应用(二十)Arcgis 栅格图像符号系统提示“This dataset does not have valid histogram required for classificati…”

flutter外包,承接flutter项目

Safe and reliable! Tianyi cloud data security management platform passed the evaluation

2021-05-02
Summary of transport layer knowledge points

保证数据库和缓存的一致性

Learning the interpretable representation of quantum entanglement, the depth generation model can be directly applied to other physical systems

Smart data won two annual awards at the second isig China Industrial Intelligence Conference

Introduction to database access tools
随机推荐
Experiment 4 operation comparison between NoSQL and relational database
阻止别人使用浏览器调试
DML:Data Manipulation Language 数据操纵语言
The relationship between derivative and differential of function
Reddit's discussion on lamda model: it is not stateless. It adopts a dual process. Compared with the way it edits Wikipedia, it doesn't matter whether it has feelings or not
2021-07-27
1. class inheritance (point)
Digital data depth | about software self-control, source code left, no code right
2020-12-20
SSH method 2 for adding node nodes in Jenkins
企业数字化不是各自发展,而是全面SaaS化推进
Is it safe to make an appointment to pay new debts? Is it reliable?
Valid parentheses
13. 罗马数字转整数
2021-08-21
Learning the interpretable representation of quantum entanglement, the depth generation model can be directly applied to other physical systems
Introduction to database access tools
2020-12-20
Autoincrement attribute of sqlserver replication table
The breakthrough of key chips hindering Huawei 5g mobile phones has been achieved, and domestic chips have gained 10% share