Sorting using Recursion function
Hi , i wrote this code ,which sort an array of floats using a recursion function (available in the code to sort just some members of the array), i finished it just like you can see, and its working well, but sometimes it turns the largest no in the array into very small no like (2.15154e-41) !!!!!!!!!!!!!!!! , try it out and tell me what do u think !!!! [try numbers in thousands ]
Code:
#include <stdio.h>
#include <iostream>
#include <conio.h>
void quicksort(int a[],int i, int j)
{
int temp =0;
for (int count=i;count<j+1;count++)
{
for (int count2=count+1;count2<j+1;count2++)
{
if (a[count]>a[count2])
{
temp=a[count];
a[count]=a[count2];
a[count2]=temp;
}
}
}
}
int main(int argc, char *argv[])
{
int marks[10];
int no;
cout<<"How many marks you have ? (MAX 10) ";
cin>>no;
for (int g=0;g<no;g++)
{
cout<<endl<<"enter mark no "<< (g+1)<<" " ;
cin>>marks[g];
}
int s,f;
cout<<"\nEnter the initial index you want to begin the sort from ";
cin>>s;
cout<<"\nEnter the finish index you want to stop the sort at ";
cin>>f;
int *p=&marks[0];
quicksort(p,s-1,f-1);
for (int l=0;l<no;l++)
{
cout<<" "<<marks[l]<<" ";
}
getche();
return 0;
}
I hope someone has the answer :) thanks