-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (52 loc) · 1.47 KB
/
main.cpp
File metadata and controls
65 lines (52 loc) · 1.47 KB
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
/********************************************************************
* Name : Kevin Shaffer
* Student ID : 106069743
* Class : CSCI 2312-001
* HW# : 2
* Due Date : Sep 12th, 2013
* Description : Creates two grids, randomizes them both, and then
multiplies them.
********************************************************************/
#include <iostream>
#include <string>
#include <time.h>
#include "main.h"
#include "grid.h"
using namespace std;
int main()
{
int x = getInput("Enter the number of rows: "),
y = getInput("Enter the number of columns: ");
// create two grids with different time based seeds
Grid grid1(x, y, time(0));
Grid grid2(x, y, time(0) + 9999);
cout << "Grid1 created" << endl;
cout << grid1.ToString() << endl << endl;
cout << "Grid2 created" << endl;
cout << grid2.ToString() << endl << endl;
grid1.Randomize();
grid2.Randomize();
cout << "Grid1 has been randomized" << endl;
cout << grid1.ToString() << endl << endl;
cout << "Grid2 had been randomized" << endl;
cout << grid2.ToString() << endl << endl;
Grid grid3 = grid1 * grid2;
cout << "Grid1 * Grid2 = " << endl;
cout << grid3.ToString() << endl << endl;
cout << "Press a key to exit: ";
cin >> x;
return 0;
}
int getInput(string question)
{
int value = 0;
// loop until user provides valid integer input
while (!value)
{
cout << question << endl;
cin >> value;
cin.clear();
cin.ignore(256,'\n');
}
return value;
}