<repo_name>jesuscardenascastro/Practica01Grupo08<file_sep>/selectionSortppc/SelectionSortPlusPlus.cpp
// heapSortV2.cpp : Este archivo contiene la función "main". La ejecución del programa comienza y termina ahí.
//

// heapSort.cpp : Este archivo contiene la función "main". La ejecución del programa comienza y termina ahí.
//

#include <stdio.h>
#include <iostream>
#include <chrono>
#include <fstream>
#include <string>
#include <windows.h>
#include <limits.h>
#include <tchar.h>
using namespace std;
using namespace std::chrono;

float t0, t1;

void swap(long int* a, long int* b)
{
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

void selectionSort( int arr[],  int n)
{
	long int i, j, midx;

	for (i = 0; i < n - 1; i++) {

		// Find the minimum element in unsorted array
		midx = i;

		for (j = i + 1; j < n; j++)
			if (arr[j] < arr[midx])
				midx = j;

		// Swap the found minimum element
		// with the first element
		swap(arr[midx], arr[i]);
	}
	
}

string getCurrentDir() {
    char buff[MAX_PATH];
    GetModuleFileName( NULL, buff, MAX_PATH );
    string::size_type position = string( buff ).find_last_of( "\\/" );
    return string( buff ).substr( 0, position);
}
int main()
{
	int arr2[] = { 100,200,300,400,500,600,700,800,900,1000,2000,3000,4000,5000,6000,7000,8000,9000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000 };
	int n = sizeof(arr2) / sizeof(arr2[0]);

	string str1 = "";

	for (int i = 0; i < n; i++) {
		int num = arr2[i];
		int* arr = nullptr;
		arr = new int[num];
		//ifstream file("E:\\2021\\UNSA\\Semestre I\\Algoritmos\\Practica\\Trabajo en equipo\\Practica01Grupo08\\Luis\\data\\archivo" + to_string(num) + ".txt");
		ifstream file(getCurrentDir() +"\\data\\archivo" + to_string(num) + ".txt");
		if (file.is_open())
		{
			for (int i = 0; i < num; ++i)
			{
				file >> arr[i];
			}
			file.close();
		}
		cout << num << endl;

		auto t0 = high_resolution_clock::now();

		selectionSort(arr, num);

		auto t1 = high_resolution_clock::now();

		/* Getting number of milliseconds as an integer. */
		auto ms_int = duration_cast<milliseconds>(t1 - t0);

		/* Getting number of milliseconds as a double. */
		duration<double, std::milli> ms_double = t1 - t0;

		str1 = str1 + to_string(num) + "," + to_string(ms_double.count()) + "\n";
	}
	ofstream MyFile(getCurrentDir() +"\\SelectionSortC.txt");
	MyFile << str1 << endl;
	MyFile.close();
	return 0;
}

<file_sep>/graficos.py
import matplotlib.pyplot as plt
import numpy as np 

from matplotlib.ticker import FormatStrFormatter, StrMethodFormatter

def main():
    #Generate Bubble Sort 
    resBubbleSortC = np.loadtxt("./ResBubbleSortCPlusPlus.txt", dtype='f')
    resBubbleSortPy = np.loadtxt("./ResBubbleSortPython.txt", dtype='f')

    
    ax = plt.subplot(1,2,1)
    # plt.subplot(1, 2, 1)
    # ax.title('Bubble Sort')
    ax.plot(resBubbleSortC[:,0],resBubbleSortC[:,1], color='green', linewidth=2.0, linestyle='-', label='C++')
    ax.plot(resBubbleSortPy[:,0],resBubbleSortPy[:,1], color='orange', linewidth=2.0, linestyle='-', label='Python')
    
    ax.yaxis.set_major_formatter(StrMethodFormatter('{x:,}'))
    ax.xaxis.set_major_formatter(StrMethodFormatter('{x:,}'))

    plt.title('Bubble Sort')
    plt.xlabel('Data')
    plt.ylabel('Miliseconds')
    plt.legend(loc='upper left')
    
    #Generate Counting Sort 
    resCountSortC = np.loadtxt("./ResCountingSortCPlusPlus.txt", dtype='f')
    resCountSortPy = np.loadtxt("./ResCountingSortPython.txt", dtype='f')
    
    ax2 = plt.subplot(1, 2, 2)
    plt.title('Counting Sort')
    ax2.plot(resCountSortC[:,0],resCountSortC[:,1], color='green', linewidth=2.0, linestyle='-', label='C++ ')
    ax2.plot(resCountSortPy[:,0],resCountSortPy[:,1], color='orange', linewidth=2.0, linestyle='-', label='Python')
    
    ax2.yaxis.set_major_formatter(StrMethodFormatter('{x:,}'))
    ax2.xaxis.set_major_formatter(StrMethodFormatter('{x:,}'))

    plt.xlabel('Data')
    plt.ylabel('Miliseconds')
    plt.legend(loc='upper left')
    
    plt.show()

main()