diff options
author | RossTheRoss <msattr@gmail.com> | 2019-04-02 15:54:57 -0500 |
---|---|---|
committer | RossTheRoss <msattr@gmail.com> | 2019-04-02 15:54:57 -0500 |
commit | da862e505457ec3ec701f7c41ecdd1061d5d1de4 (patch) | |
tree | b0eae1578ffa6317d301698723e5c041968a15d1 | |
parent | Fix an oopsie (diff) | |
download | homework-da862e505457ec3ec701f7c41ecdd1061d5d1de4.tar homework-da862e505457ec3ec701f7c41ecdd1061d5d1de4.tar.gz homework-da862e505457ec3ec701f7c41ecdd1061d5d1de4.tar.bz2 homework-da862e505457ec3ec701f7c41ecdd1061d5d1de4.tar.lz homework-da862e505457ec3ec701f7c41ecdd1061d5d1de4.tar.xz homework-da862e505457ec3ec701f7c41ecdd1061d5d1de4.tar.zst homework-da862e505457ec3ec701f7c41ecdd1061d5d1de4.zip |
AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
-rw-r--r-- | ee1301/wk5/hw5_directory/strap012_HW5A.cpp | 12 | ||||
-rw-r--r-- | ee1301/wk5/hw5_directory/strap012_HW5C.cpp | 40 | ||||
-rw-r--r-- | maze.txt | 10 | ||||
-rw-r--r-- | testData.txt | 7 |
4 files changed, 43 insertions, 26 deletions
diff --git a/ee1301/wk5/hw5_directory/strap012_HW5A.cpp b/ee1301/wk5/hw5_directory/strap012_HW5A.cpp index 4332d2d..253be9b 100644 --- a/ee1301/wk5/hw5_directory/strap012_HW5A.cpp +++ b/ee1301/wk5/hw5_directory/strap012_HW5A.cpp @@ -60,7 +60,8 @@ int main() return 0; } -//The default (no custom file) maze is procedurally generated +//The default (no custom file) maze is procedurally generated, sometimes rendering levels impossible to solve. +//This bug is not as important as finishing the monster that is 5C. void initBoardDefault(char board[lengthX][lengthY], int &xPos, int &yPos) { for (int curRow = 0; curRow < lengthY; curRow++) @@ -78,11 +79,10 @@ void initBoardDefault(char board[lengthX][lengthY], int &xPos, int &yPos) } } - board[0][0] = GOAL; - board[lengthX / 2][lengthY / 2] = ROBOT; - - xPos = lengthX / 2; - yPos = lengthY / 2; + board[rand() % lengthX][rand() % lengthY] = GOAL; + xPos = rand() % lengthX; + yPos = rand() % lengthY; + board[xPos][yPos] = ROBOT; } void initBoardCustom(char board[lengthX][lengthY], int &xPos, int &yPos) diff --git a/ee1301/wk5/hw5_directory/strap012_HW5C.cpp b/ee1301/wk5/hw5_directory/strap012_HW5C.cpp index 9948820..bfd6709 100644 --- a/ee1301/wk5/hw5_directory/strap012_HW5C.cpp +++ b/ee1301/wk5/hw5_directory/strap012_HW5C.cpp @@ -1,11 +1,37 @@ #include <iostream> +#include <string> +#include <sstream> using namespace std; -int main(int argc, char *argv[]) -{ - // if (argc != 4) { - // cout << "Invalid input!" << endl << " USAGE: ./rand-array m n max" << endl; - // return 2; - // } - +#define SIZE 100 +int maxRow = 0, maxColumn = 0; +void getInput(int input[SIZE][SIZE]); +int main() { + int column = 0, row = 0; + /* + Array is set up as follows + C + R 0 1 ... + 1 + ... + */ + int inputArray[SIZE][SIZE] = {0}; + getInput(inputArray); + +} + +void getInput(int input[SIZE][SIZE]) { + string test; + while (getline(cin,test)) { + istringstream ss(test); + string temp; + while(getline(ss,temp,' ')) + maxRow=0; + { + input[maxRow][maxColumn] = stoi(temp); + maxRow++; + } + maxColumn++; + } + cout << maxRow << " " << maxColumn << endl; }
\ No newline at end of file diff --git a/maze.txt b/maze.txt deleted file mode 100644 index cd95590..0000000 --- a/maze.txt +++ /dev/null @@ -1,10 +0,0 @@ -WWWW-O-WWW ----W------ ---WWWWWW-W ----------- -WWWWWWWWW- ----------- --WW-WW-WW- ----------- -WW-WW-WW-W -X---------
\ No newline at end of file diff --git a/testData.txt b/testData.txt index f067f0b..b0628c2 100644 --- a/testData.txt +++ b/testData.txt @@ -1,3 +1,4 @@ --14 58 22 -4 --63 -24 -5 -4 --12 48 -39 -82 +33 44 96 -13 +-40 -72 -17 -87 +-13 -89 11 -51 +-3 -64 19 -75 |