当前位置:网站首页>Bubble sorting with C language
Bubble sorting with C language
2022-06-11 07:52:00 【zljun8210】
Learn to use C Language for bubble sorting , The code is as follows :
/*
============================================================================
Name : BubbleSort.c
Author : zlj
Version :
Copyright : soft.rz
Description : Hello World in C, Ansi-style
============================================================================
*/
#include <stdio.h>
#define SIZE 11
void bubble_sort(int a[], int n);
void bubble_sort(int a[], int n)
{
int i, j, temp;
for (j = 0; j < n - 1; j++)
{
for (i = 0; i < n - 1 - j; i++)
{
if(a[i] > a[i + 1])
{
temp = a[i];
a[i] = a[i + 1];
a[i + 1] = temp;
}
}
printf(" The first %d Round order : \n", j+1);
for (int k =0;k<n;k++)
{
printf("%d \t", a[k]);
}
printf("\n");
}
}
int main()
{
int number[SIZE] = {95, 45, 15, 78, 84, 51, 24, 12, 38, 52, 66};
int i;
printf(" Bubble sort original data is :\n");
for (i = 0; i < SIZE; i++)
{
printf("%d\t", number[i]);
}
printf("\n\n");
bubble_sort(number, SIZE);
printf("\n The final data is :\n");
for (i = 0; i < SIZE; i++)
{
printf("%d\t", number[i]);
}
}
The results are as follows :

边栏推荐
- 空间几何
- 零基础自学SQL课程 | OUTER JOIN外连接
- Clipping and overlapping of YUV data
- Uoj 553 [unr 4] caproic acid set [computational geometry (points in circle → points in half plane)]
- 2022.6.6 extra long growth simulation
- 860. 柠檬水找零
- Request request object and response response object
- Qunhui ds918 creates m.2 SSD read / write cache
- C# 微信上传Form-data
- Note: JDBC
猜你喜欢

Tidb cloud launched Google cloud marketplace, empowering global developers with a new stack of real-time HTAP databases

TiDB Cloud 上线 Google Cloud Marketplace,以全新一栈式实时 HTAP 数据库赋能全球开发者
![2020080 simulation competition [horizontal and vertical coordinates do not affect each other, cactus minimum cut, combined meaning translation formula]](/img/4d/a67a63d2c4eb80c98315c3057b01b9.jpg)
2020080 simulation competition [horizontal and vertical coordinates do not affect each other, cactus minimum cut, combined meaning translation formula]

Figure seamless database integration tushare interface
![[IOT] project management: how to build a better cross functional team?](/img/df/28dbf0f7ba75d1bb3469cc15e70538.png)
[IOT] project management: how to build a better cross functional team?

C language - Growth Diary -01- count primes and sum
![[atcoder2306] rearranging (topology)](/img/b3/38589a07a7c26bea8ed154ab794760.png)
[atcoder2306] rearranging (topology)

Deux diplômés, la Banque a externalisé le travail d'essai pendant plus de quatre mois. Parler de vrais sentiments...

放大镜子效果图

二本畢業,銀行外包測試工作 4 個月有餘。聊聊一些真實感受 ...
随机推荐
JSP technology: JSP overview, JSP basic syntax, JSP instructions, JSP implicit objects, JSP action elements
安卓初中级开发基础知识整理(面试自用)
远程办公经验分享 | 社区征文
【案例解读】医疗单据OCR识别助力健康险智能理赔
[cluster] haproxy load balancing
Bidirectional linked list simple template (pointer version)
El expressions and JSTL
A detailed explanation of one of the causes of dead loop caused by array out of bounds in C language
C language to achieve a simple game - minesweeping
Remote office experience sharing | community essay solicitation
2022.6.6 extra long growth simulation
Activity中,View#postDelay会导致内存泄漏,但是不会影响Activity的生命周期执行。
Understanding of Poisson distribution and Poisson process and Erlang distribution and their relations (important theories in queuing theory and operational research)
String Simulation Implementation
Lesson 1 about Xiaobai's C language
Tidb Cloud est en ligne sur le marché Google Cloud pour permettre aux développeurs du monde entier d'utiliser une nouvelle pile de bases de données htap en temps réel
Semiconductor memory classification
Servlet
Image data enhancement (translation, rotation, brightness transformation, flipping, adding Gaussian noise, scaling, cropping)
Simple use of string