help me please

include <iostream.h>
#include <conio.h>
class matrik
{ private:
int vMatrik[100];
int baris, kolom;
char nama;
public:
matrik(…){ … }
~matrik() {;}
void newValue( … ) { … }
void setNama( … ) { … }
void setDimensi( … ) { … }
void clear() { … }
void print() { … }
matrik operator +( … ) { … }
matrik operator -( … ) { … }
void operator -() { … }
matrik operator *( … ) { … }
};
int main()
{
const baris_data1 = 3, kolom_data1 = 3;
const baris_data2 = 3, kolom_data2 = 4;
int data1[10][10] = { {1, 2, 3},
{4, 5, 6},
{7, 8, 9}};
int data2[10][10] = { {0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 0, 1}};
matrik *pA = new matrik(baris_data1, kolom_data1, 'A');
matrik *pB = new matrik(baris_data2, kolom_data2, 'B');
matrik *pC = new matrik(baris_data1, kolom_data1, 'C');
cout << "Uji nilai awal semua obyek adalah 0\n";
pA -> print(); pB -> print(); pC -> print();
cout << "Tekan sembarang tombol..."; getch(); clrscr();
cout << "Uji pemberian nilai baru\n";
pA -> newValue(data1); pB -> newValue(data2);
pA -> print(); pB -> print(); pC -> print();
cout << "Tekan sembarang tombol..."; getch(); clrscr();
cout << "Uji operasi jumlah : C = A + A\n";
cout << "Data awal\n";
pA -> print(); pC -> print();
*pC = *pA + *pA;
pC -> setNama('C');
cout << "Hasil operasi\n";
pA -> print(); pC -> print();
cout << "Tekan sembarang tombol..."; getch(); clrscr();
cout << "Uji operasi selisih: A = A - C\n";
cout << "Data awal\n";
pA -> print(); pC -> print();
*pA = *pA - *pC;
pA -> setNama('A');
cout << "Hasil operasi\n";
pA -> print(); pC -> print();
cout << "Tekan sembarang tombol..."; getch(); clrscr();
cout << "Uji operasi negasi: -A.\n";
cout << "Data awal\n";
pA -> print();
-*pA;
cout << "Hasil operasi\n";
pA -> print();
cout << "Tekan sembarang tombol..."; getch(); clrscr();
cout << "Uji operasi kali: C = A x B\n";

pC -> setDimensi(baris_data1, kolom_data2);
pC -> clear();
cout << "Data awal\n";
pA -> print(); pB -> print(); pC -> print();
*pC = *pA * *pB;
pC -> setNama('C');
cout << "Hasil operasi\n";
pC -> print();
cout << "Sukses...";
delete pA; delete pB; delete pC; getch(); return 0;

}


implementation



Uji nilai awal obyek adalah 0
A=
0 0 0
0 0 0
0 0 0
B=
0 0 0 0
0 0 0 0
0 0 0 0
C=
0 0 0
0 0 0
0 0 0
Tekan sembarang tombol...
Uji pemberian nilai baru
A=
1 2 3
4 5 6
7 8 9

B=
0 1 2 3
4 5 6 7
8 9 0 1

C=
0 0 0
0 0 0
0 0 0

Tekan sembarang tombol...
Uji operasi jumlah : C = A + A
Data awal
A=
1 2 3
4 5 6
7 8 9

C=
0 0 0
0 0 0
0 0 0

Hasil operasi
A=
1 2 3
4 5 6
7 8 9

C=
2 4 6
8 10 12
14 16 18

Tekan sembarang tombol...
Uji operasi selisih: A = A - C
Data awal
A=
1 2 3
4 5 6
7 8 9

C=
2 4 6
8 10 12
14 16 18

Hasil operasi
A=
-1 -2 -3
-4 -5 -6
-7 -8 -9

C=
2 4 6
8 10 12
14 16 18

Tekan sembarang tombol...
Uji operasi negasi: -A.
Data awal
A=
-1 -2 -3
-4 -5 -6
-7 -8 -9

Hasil operasi
A=
1 2 3
4 5 6
7 8 9

Tekan sembarang tombol...
Uji operasi kali: C = A x B
Data awal
A=
1 2 3
4 5 6
7 8 9

B=
0 1 2 3
4 5 6 7
8 9 0 1

C=
0 0 0 0
0 0 0 0
0 0 0 0

Hasil operasi
C=
32 38 14 20
68 83 38 53
104 128 62 86

Sukses...







Please use code tags around the code aka this <> located in the format sections.
Also what exactly do you need help with we need more info than what you have given.
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <conio.h>
class matrik
{ private:
int vMatrik[100];
int row, col;
char Name;
public:
  matrik(){

       }
~matrik() {;}
void newValue( … ) {

 }
void setName( … ) {

 }
void setDimensi(  ) {

}
void clear() {
 }
void print() {

}
matrik operator +( ) {

}
matrik operator -( ) {
 }
void operator -() {
 }
matrik operator *(  ) {

}
};
int main()
{
const row_data1 = 3, col_data1 = 3;
const row_data2 = 3, col_data2 = 4;
int data1[10][10] =
{ {1, 2, 3},
{4, 5, 6},
{7, 8, 9}};
int data2[10][10] = {
{0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 0, 1}};
      matrik *pA = new matrik(row_data1, col_data1, 'A');
      matrik *pB = new matrik(row_data2, col_data2, 'B');
      matrik *pC = new matrik(row_data1, col_data1, 'C');


cout << "Test the initial value of all objects are 0\n";
        pA -> print();
        pB -> print();
        pC -> print();
         cout << "Press any key...";
        getch();
        clrscr();

cout << "Test provision of new value\n";
      pA -> newValue(data1);
     pB -> newValue(data2);
     pA -> print(); pB -> print();
     pC -> print();
     cout << "Press any key...";
getch();
clrscr();


cout << "The summing operation test : C = A + A\n";
cout << "initial contents of the data\n";
          pA -> print(); 
          pC -> print();
         *pC = *pA + *pA;
          pC -> setName('C');
         cout << "operating results\n";
          pA -> print(); pC -> print();
           cout << "Press any key...";
 getch();
 clrscr();

cout << "Test subtraction operation: A = A - C\n";
cout << "initial contents of the data\n";
          pA -> print(); 
          pC -> print();
       *pA = *pA - *pC;
          pA -> setName('A');
cout << "operating results\n";
          pA -> print(); 
          pC -> print();
cout << "Press any key...";
getch();
clrscr();

cout << "Test operation of negation: -A.\n";
cout << "initial contents of the data\n";
           pA -> print();
           -*pA;
          cout << "operating results\n";
            pA -> print();
cout << "Press any key...";
getch();
clrscr();


cout << "Test operation of multiplication: C = A x B\n";

pC -> setDimensi(row_data1, col_data2);
pC -> clear();
cout << "initial contents of the data\n";
pA -> print(); 
pB -> print(); 
pC -> print();
*pC = *pA * *pB;
pC -> setName('C');
cout << "operating results\n";
pC -> print();
cout << "Success...";
       delete pA;
       delete pB; 
       delete pC;
getch();
return 0;

}
Last edited on


Test the initial value of all objects are 0
A=
0 0 0
0 0 0
0 0 0
B=
0 0 0 0
0 0 0 0
0 0 0 0
C=
0 0 0
0 0 0
0 0 0
Press any key......






Test provision of new value
A=
1 2 3
4 5 6
7 8 9

B=
0 1 2 3
4 5 6 7
8 9 0 1

C=
0 0 0
0 0 0
0 0 0

Press any key...




The summing operation test : C = A + A
initial contents of the data
A=
1 2 3
4 5 6
7 8 9

C=
0 0 0
0 0 0
0 0 0

operating results
A=
1 2 3
4 5 6
7 8 9

C=
2 4 6
8 10 12
14 16 18

Press any key...




Uji operasi negasi: -A.
initial contents of the data
A=
-1 -2 -3
-4 -5 -6
-7 -8 -9

operating results
A=
1 2 3
4 5 6
7 8 9

Press any key...





Test operation of multiplication: C = A x B
initial contents of the data
A=
1 2 3
4 5 6
7 8 9

B=
0 1 2 3
4 5 6 7
8 9 0 1

C=
0 0 0 0
0 0 0 0
0 0 0 0

operating results
C=
32 38 14 20
68 83 38 53
104 128 62 86

Success...


Last edited on
Topic archived. No new replies allowed.