Total members 11708 |It is currently Wed Apr 25, 2018 8:52 pm Login / Join Codemiles

### Weka

Well I'm kinda new to programming and since i didn't see this sort on this site I thought that I'd post mine. Just made this last night just to see if I could. If you see any errors please point them out.
cpp code
`#include<iostream>int* BubbleSort(int* a);using namespace std;void main(){   	int sort[10], i;	int* psort = 0;	psort = sort;	printf("Enter 10 numbers: \n");	for(i=0; i<10; i++) {		printf("%d: ", (i+1));		cin >> sort[i];	}		printf("\nBefore sorted: ");	for(i=0; i < 10; i++) {		printf("%d ", sort[i]);	}	printf("\n\n After Sorted: ");	psort = BubbleSort(psort);		for(i=0; i < 10; i++) {		printf("%d ", sort[i]);	}	printf("\n");}int* BubbleSort(int* a) { 	int c = 0;	int d = 0;	do {		d = 0;		for(int b = 0; b < 9; b++) {			if(a[b] > a[b+1]) {				c = a[b];				a[b] = a[b+1];				a[b+1] = c;				d++;				}			}		}while(d);	return a;}`

This algorithm is one of the simplest and easiest to understand but it is very inefficient so I wouldn't use it for anything serious.
This sorts out 10 integers in an array and puts them from lowest to highest order.

 Tweet
Author:
 Posts: 2Have thanks: 0 time

Thanks "Shimano" for your post .

About my self i made the bubble sort before by my self but i don;t know where the code gone . thanks and keep sharing your work , i am sure it will be helpful to someone .

 Tweet
Author:
 Posts: 2707Have thanks: 74 time
 Page 1 of 1 [ 2 posts ]

Related Posts  to : C++ Bubble Sort
bidirectional bubble sort algorithm implementation java     -
Bubble Sort Algorithm Java Implementation Code-Sorting Array     -
C++ Selection Sort     -
sort words in c++     -
Library Sort     -
String Sort     -
selection sort     -
Sort a list     -
Insertion Sort (C++)     -
Array sort     -

C++ Sorting