Update MP2
This commit is contained in:
@@ -13,21 +13,19 @@
|
||||
#include <iostream>
|
||||
#include <ncurses.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
#include "rockPaperScissors.h"
|
||||
#include "main.h"
|
||||
#include "2DArrayOperations.h"
|
||||
#include "binarySearch.h"
|
||||
|
||||
int main(){
|
||||
|
||||
std::vector<std::vector<int>> vector = {
|
||||
{1, 2, 3, 4},
|
||||
{5, 6, 7, 8},
|
||||
{9, 10, 11, 12},
|
||||
{13, 14, 15, 16}
|
||||
};
|
||||
|
||||
std::vector<std::vector<int>> vector;
|
||||
std::vector<std::tuple<int, int>> highlightTuple; // collection of tuples to highlight
|
||||
int ch;
|
||||
static int selection = 0;
|
||||
static int * selectionPointer = &selection;
|
||||
@@ -55,24 +53,41 @@ int main(){
|
||||
gameLoop();
|
||||
break;
|
||||
case 1:
|
||||
attrset(A_NORMAL);
|
||||
endwin();
|
||||
cout << "\033[2J\033[1;1H"; // Clear screen unicode sequence
|
||||
printf("2D Vector:\n%s\n", printVector(vector).c_str());
|
||||
printf("getTotal: %i\n", getTotal(vector));
|
||||
vector = random2DArray(10, 10);
|
||||
std::sort(vector.begin(), vector.end());
|
||||
printf("Binary search is being used to locate the tuples to highlight!\n");
|
||||
printf("getAverage: %i\n", getAverage(vector));
|
||||
printf("getRowTotal 0: %i\n", getRowTotal(vector, 0));
|
||||
printf("getColumnTotal 0: %i\n", getColumnTotal(vector, 0));
|
||||
printf("getHighestInRow 0: %i\n", getHighestInRow(vector, 0));
|
||||
highlightTuple.push_back(binarySearch(vector, getHighestInRow(vector, 0)));
|
||||
printf("getHighestInColumn 0: %i\n", getHighestInColumn(vector, 0));
|
||||
highlightTuple.push_back(binarySearch(vector, getHighestInColumn(vector, 0)));
|
||||
printf("getLowestInRow 3: %i\n", getLowestInRow(vector, 3));
|
||||
highlightTuple.push_back(binarySearch(vector, getLowestInRow(vector, 3)));
|
||||
printf("getLowestInColumn 3: %i\n", getLowestInColumn(vector, 3));
|
||||
highlightTuple.push_back(binarySearch(vector, getLowestInColumn(vector, 3)));
|
||||
printf("2D Vector: %s \n", printVector(vector, highlightTuple).c_str());
|
||||
cout << "Press Enter to Continue";
|
||||
getchar();
|
||||
attron(A_NORMAL);
|
||||
break;
|
||||
case 2:
|
||||
attrset(A_NORMAL);
|
||||
endwin();
|
||||
cout << "\033[2J\033[1;1H"; // Clear screen unicode sequence
|
||||
|
||||
vector = random2DArray(10, 10);
|
||||
std::sort(vector.begin(), vector.end());
|
||||
printf("2D Vector:\n%s\n", printVector(vector).c_str());
|
||||
printf("getHighestInRow 0: %i\n", getHighestInRow(vector, 0));
|
||||
std::tuple result = binarySearch(vector, getHighestInRow(vector, 0));
|
||||
printf("binary search for results from getHigestInARow(0): %i, %i\n", get<0>(result), get<1>(result));
|
||||
cout << "Press Enter to Continue";
|
||||
getchar();
|
||||
attron(A_NORMAL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -100,7 +115,7 @@ std::string printMenu(int* selection) {
|
||||
const int ARRAY_SIZE = 3;
|
||||
std::string outputString = "";
|
||||
std::string cursor[ARRAY_SIZE] = {"> ", " ", " "};
|
||||
std::string menu[ARRAY_SIZE] = {"Rock Paper Scissors", "2D Arrays", "Binary Search"};
|
||||
std::string menu[ARRAY_SIZE] = {"Rock Paper Scissors", "2D Arrays (demonstrates binary search, too!)", "Binary Search"};
|
||||
//printf("%i", *selection);
|
||||
/*
|
||||
if (*selection >= ARRAY_SIZE - 1) {
|
||||
|
Reference in New Issue
Block a user