this is the sample program of selection sort, which is given the value. But, how to call the value from read file? anybody knows?
#include <iostream>
using namespace std;
void selectionSort(int *y,int n)//selection sort function
{
int i,j,min,minat;
for(i=0;i<n;i++)
{
minat=i;
min=y[i];
for(j=i+1;j<(n);j++) //select the min of the rest of array
{
if(min<y[j]) //ascending order for descending reverse
{
minat=j; //the position of the min element
min=y[j];
}
}
int temp=y[i] ;
y[i]=y[minat]; //swap
y[minat]=temp;
}
}
void printElements(int *y,int n) //print array elements
{
int i=0;
for(i=0;i<4;i++)
cout<<y[i]<<endl;
}
void main()
{
int y[]={9,6,5,23}; // array to sort
selectionSort(y,4); //call to selection sort
printElements(y,4); // print elements
}