#include "StdAfx.h"
#include "Sorting.h"

Sorting::Sorting(void)
{
}

Sorting::~Sorting(void)
{
}

void Sorting::bubbleSort(int data[], int size)
{
	double temp;
	for (int i=0; i<size;i++)
	{
		for(int j=0;j<size-1;j++)
		{
			if(data[j] > data[j+1])
			{
				temp=data[j];
				data[j] = data[j+1];
				data[j+1] = temp;
			}
		}
	}
}

int Sorting::findMinIndex(int data[], int size)
{
	int min = 0;
	for (int i=1; i<size;i++)
	{
		if (data[min] > data[i])
			min = i;
	}
	return min;
}

void Sorting::selectionSort(int data[], int size)
{
	int los;
	int temp;

	for (int i=0; i<size; i++)
	{
		los = i;
		for(int j=i; j<size; j++)
		{
			if (data[j] < data[los])
				los = j;
		}
		temp = data[i];
		data[i] = data[los];
		data[los] = temp;
	}
}

int Sorting::findMaxIndex(int data[], int size)
{
	int max = 0;
	for (int i=1; i<size;i++)
	{
		if (data[max] < data[i])
			max = i;
	}
	return max;
}