Kayoung

Modify PrintProgram

...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
2 #include <iomanip> 2 #include <iomanip>
3 using namespace std; 3 using namespace std;
4 4
5 -void printMatrix(int(*inMatrix)[4]) { 5 +void printMatrix(int(*inMatrix)[5]) {
6 - for (int i = 0; i < 4; i++) { 6 + for (int i = 0; i < 5; i++) {
7 - for (int j = 0; j < 4; j++) { 7 + for (int j = 0; j < 5; j++) {
8 - cout << left << setfill(' ') << setw(5) << inMatrix[i][j]; 8 + cout << left << setfill(' ') << setw(8) << inMatrix[i][j];
9 } 9 }
10 cout << endl; 10 cout << endl;
11 } 11 }
...@@ -13,12 +13,12 @@ void printMatrix(int(*inMatrix)[4]) { ...@@ -13,12 +13,12 @@ void printMatrix(int(*inMatrix)[4]) {
13 13
14 int main() { 14 int main() {
15 srand((unsigned int)time(NULL)); 15 srand((unsigned int)time(NULL));
16 - int matrix1[4][4]; 16 + int matrix1[5][5];
17 - int matrix2[4][4]; 17 + int matrix2[5][5];
18 - int sum[4][4]; 18 + int sum[5][5];
19 - int mul[4][4]; 19 + int mul[5][5];
20 - for (int i = 0; i < 4; i++) { 20 + for (int i = 0; i < 5; i++) {
21 - for (int j = 0; j < 4; j++) { 21 + for (int j = 0; j < 5; j++) {
22 matrix1[i][j] = rand() % 101; 22 matrix1[i][j] = rand() % 101;
23 matrix2[i][j] = rand() % 101; 23 matrix2[i][j] = rand() % 101;
24 sum[i][j] = matrix1[i][j] + matrix2[i][j]; 24 sum[i][j] = matrix1[i][j] + matrix2[i][j];
......