From 1f0036528393478007640698858eb6079dc8d2fe Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Mon, 1 Apr 2019 11:06:07 -0500 Subject: Start HW --- ee1301/wk5/hw5_directory/strap012_HW5B.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ee1301/wk5/hw5_directory/strap012_HW5B.cpp (limited to 'ee1301/wk5/hw5_directory/strap012_HW5B.cpp') diff --git a/ee1301/wk5/hw5_directory/strap012_HW5B.cpp b/ee1301/wk5/hw5_directory/strap012_HW5B.cpp new file mode 100644 index 0000000..4576e59 --- /dev/null +++ b/ee1301/wk5/hw5_directory/strap012_HW5B.cpp @@ -0,0 +1,30 @@ +#include +#include +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; + } + srand(time(NULL)); + int m, n, max; + m = atoi(argv[1]); //number of rows + n = atoi(argv[2]); //number of columns + int randArray[m][n]; + max = atoi(argv[3]); //Maximum number + for (int curRow = 0; curRow < m; curRow++) + { + for (int curCol = 0; curCol < n; curCol++) + { + if (rand() % 2 == 1) { + randArray[curRow][curCol] = -1 * (rand() % max); + } else { + randArray[curRow][curCol] = (rand() % max); + } + } + } + + cout << endl; +} \ No newline at end of file -- cgit v1.2.3