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 66 67 68 69 70
|
#include <iostream>
#include <cstdlib>
using namespace std;
int populate_matrix (int matrix[100][100], int height, int width);
bool multiply_matrix (int matrix_a [100][100],
int aheight, int awidth, int matrix_b [100][100],
int bheight, int bwidth, int matrix_c [100][100],
int& cheight, int& cwidth);
void print_matrix (int matrix [100][100], int height, int width);
long int seeder();
int generate (int);
int main()
{
int number, aheight, awidth, bheight, bwidth, height, width;
int matrix[100][100];
int A [100][100];
int B [100][100];
int C [100][100];
seeder();
cout << "\nMatrix A Height = ";
cin >> aheight;
cout << "\nMatrix A Width = ";
cin >> awidth;
cout << "\nMatrix B Height = ";
cin >> bheight;
cout << "\nMatrix B Width = ";
cin >> bwidth;
int populate_matrix (int matrix[100][100], int height, int width);
for ( height = 0; height < aheight; height++ )
{
for ( width = 0; width < awidth; width++ )
cout << matrix [height][width];
cout << endl;
}
}
long int seeder()
{
long int sprout;
cout << "Please input any number (no larger than 9 digits please) of your choosing." << endl;
cout << "It will be used by the program to generate random numbers for the matrix.\n" << endl;
cout << "Enter your chosen number - ";
cin >> sprout;
srand( sprout );
return sprout;
}
int generate(int number)
{
number = rand() % 100;
return number;
}
int populate_matrix (int matrix[100][100], int height, int width)
{
int aheight, awidth, number, input;
for ( height = 0; height < aheight; height++ )
{
for ( width = 0; width < awidth; width++ )
input = generate(number);
matrix[height][width] = input;
}
}
|