Bubble sort C

Source: Internet
Author: User

#include <stdio.h>
#include <string.h>
int fun (int *a,int n) {
for (int i=0; i<8; i++) {//The function of this loop is to perform the following loop multiple times
for (int j=0; j<n-i; J + +) {//The function of a loop is to compare the number before and the back of the sort
if (A[j]>a[j+1]) {//two digits it's bigger, it's in the back.
int C=A[J];
for (int k=0; k<n; k++) {//The function of this loop is to put the newly sorted output
printf ("%3d\n", A[k]);
return 0;
int main () {
int a[8]={12,32,13,45,98,67,47,89};//wanted to use the keyboard to enter, but it took a long time the size of the array or to be fixed
printf ("%d", Fun (a,8));

Bubble sort C

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.