aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk5/hw5_directory/strap012_HW5B.cpp
diff options
context:
space:
mode:
authorRossTheRoss <msattr@gmail.com>2019-04-01 11:06:07 -0500
committerRossTheRoss <msattr@gmail.com>2019-04-01 11:06:07 -0500
commit1f0036528393478007640698858eb6079dc8d2fe (patch)
treec21e68d45ef562e1867b76d6477f2d65401d46d0 /ee1301/wk5/hw5_directory/strap012_HW5B.cpp
parentDO not much really (diff)
downloadhomework-1f0036528393478007640698858eb6079dc8d2fe.tar
homework-1f0036528393478007640698858eb6079dc8d2fe.tar.gz
homework-1f0036528393478007640698858eb6079dc8d2fe.tar.bz2
homework-1f0036528393478007640698858eb6079dc8d2fe.tar.lz
homework-1f0036528393478007640698858eb6079dc8d2fe.tar.xz
homework-1f0036528393478007640698858eb6079dc8d2fe.tar.zst
homework-1f0036528393478007640698858eb6079dc8d2fe.zip
Start HW
Diffstat (limited to 'ee1301/wk5/hw5_directory/strap012_HW5B.cpp')
-rw-r--r--ee1301/wk5/hw5_directory/strap012_HW5B.cpp30
1 files changed, 30 insertions, 0 deletions
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 <iostream>
+#include <cstdlib>
+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