1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
#include <iostream>
#include <fstream>
#include "Merge.h"
#include "Quick.h"
#include "Insertion.h"
#include "Bubble.h"
#include "Selection.h"
using namespace std;
char showMenu();
int main()
{
char choice;
const int SIZE = 12;
int courseNum[12];
int sectionNum[12];
//int a[] {8, 5, 10, 4, 3, 11, 6, 7, 2, 1};
ifstream file("textfile.txt");
if (file.is_open())
{
for (int i = 0; i < 12; i++)
{
file >> courseNum[i];
//file >> sectionNum[i];
}
}
for (int i = 0; i < 12; i++)
{
cout << courseNum[i]; //<< " " << sectionNum[i];
cout << endl;
}
QuickSort qSort;
MergeSort mSort;
BubbleSort bSort;
InsertionSort iSort;
SelectionSort sSort;
do
{
choice = showMenu();
switch (choice)
{
case 'A':
/*sSort.print(a, 0, SIZE - 1);
cout << endl;
sSort.selectionSort(a, SIZE);
sSort.print(a, 0, SIZE - 1);
cout << endl;*/
break;
case 'B':
bSort.BubbleSorting(courseNum, SIZE);
bSort.print(courseNum, SIZE);
cout << endl;
break;
case 'C':
/*iSort.print(a, 0, SIZE - 1);
cout << endl;
iSort.insertionSort(a, SIZE);
iSort.print(a, 0, SIZE - 1);
cout << endl;*/
break;
case 'D':
break;
case 'E':
/*qSort.print(a, 0, SIZE - 1);
cout << endl;
qSort.quickSort(a, SIZE);
qSort.print(a, 0, SIZE - 1);
cout << endl;*/
break;
case 'F':
/*mSort.print(a, 0, SIZE - 1);
cout << endl;
mSort.mergeSort(a, SIZE);
mSort.print(a, 0, SIZE - 1);
cout << endl << endl;
break;*/
default:
break;
}
} while (choice != 'G');
return 0;
}
char showMenu()
{
char select;
cout << "\nMenu\n";
cout << "========\n";
cout << "A. Selection\n";
cout << "B. Bubble\n";
cout << "C. Insertion\n";
cout << "D. Heap\n";
cout << "E. Quick\n";
cout << "F. Merge\n";
cout << "G. Exit\n";
cout << endl;
cout << "Choice: ";
cin >> select;
return select;
}
|