Contoh Matrix transpose

26 Mei

#include
#include
#include
#include
class matriks{
friend istream& operator>>(istream&, matriks&);
friend ostream& operator<<(ostream&, matriks&);
public:
void baca_matriks();
matriks& transpose(const matriks&);
private:
int baris, kolom;
int A[10][10];
};
void matriks::baca_matriks(){
int i,j;
for(i=0; i<baris; i++)
for(j=0;j<kolom;j++){
cout<<"Data["<<i+1<<"],["<<j+1<>A[i][j];
}
}
matriks& matriks::transpose(const matriks& matrik){
int i,j;
baris=matrik.kolom;
kolom=matrik.baris;
for(i=0;i<baris;i++)
for(j=0;j>(istream& in, matriks& A){
cout<>A.baris;
cout<>A.kolom;
cout<<"Masukkan data matriks\n";
A.baca_matriks();
return in;
}
ostream& operator<<(ostream& out, matriks& A){
int i,j;
for(i=0;i<A.baris;i++)
{
for(j=0;j<A.kolom;j++)
cout <<setw(5)<<A.A[i][j]<<" ";
cout <<endl;
}
return out;
}
int main(){
matriks matrik, T;
cout<>matrik;
cout<<"Data Matrik :\n"; cout <<matrik;
cout<<"Hasil Transpose : \n";
T.transpose(matrik);
cout << T;
getch();
return 0;
}

// Selamat mencoba…semoga sukses…!!
Nikmati dunia pemrograman….
😀

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: