#include "stdafx.h" #include<iostream> using namespace std; void Swap(int *elem1, int *elem2) { int temp = *elem1; *elem1 = *elem2; *elem2 = temp; } void bobbleSort(int a[], int length) { for(int i=0;i<length-1;i++) for(int j=length-1;j>i;j--) if(a[j-1]>a[j]) Swap(&a[j-1],&a[j]); } int main() { int a[]={4,6,8,1,2,9,3,7,5}; bobbleSort(a,9); for(int i=0;i<9;i++) cout<<a[i]; system("pause"); return 0; }