void bubbleSort(int aray[],int length)//Bubble sort function { int i,j; for(i=0;i<length;i++) { for(j=0;j<i;j++) { if(aray[i]>aray[j]) { int temp=aray[i]; //swap
aray[i]=aray[j]; aray[j]=temp; }
} } } int _tmain(int argc, _TCHAR* argv[]) { int n; int array1[100]; cout<<"Enter the number of elements : "; cin>>n; for(int i=0;i<n;i++){ cout<<"Enter the "<<i+1<<" element : "; cin>>array1[i]; } bubbleSort(array1,n); for(int i=0;i<n;i++){ cout<<array1[i]<<" "; } cout<<" Press any key to exit...."; getch();
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment