A bigger bubble sort application : Bubble Sort « Data Structure Algorithm « C / ANSI-C

Home
C / ANSI-C
1.assert.h
2.Console
3.ctype.h
4.Data Structure Algorithm
5.Data Type
6.Development
7.File
8.Function
9.Language Basics
10.Macro Preprocessor
11.Math
12.math.h
13.Memory
14.Pointer
15.setjmp.h
16.signal.h
17.Small Application
18.stdio.h
19.stdlib.h
20.String
21.string.h
22.Structure
23.time.h
24.wctype.h
C Tutorial
C++
C++ Tutorial
Visual C++ .NET
C / ANSI-C » Data Structure Algorithm » Bubble SortScreenshots 
A bigger bubble sort application

#include<stdio.h>

int bubble(int x[],int n) {

 int hold,j,pass,i,switched = 1;

 for(pass = 0; pass < n-&& switched == 1;pass++) {
    switched=0;

    for (j=0;j<n-pass-1;j++)
        if (x[j]>x[j+1]) {
            switched=1;
            hold = x[j];
            x[j= x[j+1];
            x[j+1]=hold;
        }
    }
    return(0);
}
int main() {
  int marks[10];
  int i;

  marks[039;
  marks[155;
  marks[243;
  marks[243;
  marks[349;
  marks[412;
  marks[52;
  marks[65;
  marks[74;
  marks[83;
  marks[91;
  bubble(marks, 10);

  for(i =0;i<10;i++){
      printf("%d ",marks[i]);
  }
}
           
       
Related examples in the same category
1.The Bubble Sort
2.A bubble sort on int array
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.