1.
SCREEN SHOT PROGRAM
2.
KODE PROGRAM
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
main()
int a[100][100]; // array matriks A
int b[100][100]; // array Matriks B
int c[100][100]; // array Matriks C
int jml_br; // jumlah baris yang
diinput
int jml_kl; // jumlah kolom yang
diinput
int br,kl; // baris, kolom untuk
perulangan for
clrscr();
puts("
--------------------------------------------------- ");
puts(" TUGAS LOGIKA &
ALGORITMA KELAS 13.1C.21 PERTEMUAN 9 ");
puts("
--------------------------------------------------- ");
puts(" ANGGOTA KELOMPOK :
");
puts(" 1. 13141169 - Iwan
Herdinan ");
puts(" 2. 13141169 - Dwi Yuli
Wibowo ");
puts("
--------------------------------------------------- ");
puts(" PENJUMLAHAN &
PENGURANGAN 2 BUAH MATRIKS");
puts(" ---------------------------------------------------
");
cout<<" Masukkan Jumlah
Baris Matriks = ";cin>>jml_br;
cout<<" Masukkan Jumlah
Kolom Matriks = ";cin>>jml_kl;
cout<<endl;
//input nilai Matriks [A]
cout<<" Matriks [A]
:"<<endl;
for(br=1;br<=jml_br;br++)
{
for (kl=1;kl<=jml_kl;kl++)
{
cout<<" Input Nilai Baris
ke-"<<br<<", Kolom ke-"<<kl<<" =
";cin>>a[br][kl];
}
}
cout<<endl;
//input nilai Matriks [B]
cout<<" Matriks [B]
:"<<endl;
for(br=1;br<=jml_br;br++)
{
for (kl=1;kl<=jml_kl;kl++)
{
cout<<" Input Nilai Baris
ke-"<<br<<", Kolom ke-"<<kl<<" =
";cin>>b[br][kl];
}
}
cout<<endl<<endl;
//Tampilkan Matriks [A]
cout<<" Matriks [A]
:"<<endl;
for(br=1;br<=jml_br;br++)
{
for (kl=1;kl<=jml_kl;kl++)
{
cout<<setiosflags(ios::right)<<setw(10)<<a[br][kl];
}
cout<<endl;
}
cout<<endl<<endl;
//Tampilkan Matriks [B]
cout<<" Matriks [B]
:"<<endl;
for(br=1;br<=jml_br;br++)
{
for (kl=1;kl<=jml_kl;kl++)
{
cout<<setiosflags(ios::right)<<setw(10)<<b[br][kl];
}
cout<<endl;
}
cout<<endl<<endl;
//Jumlahkan Matriks [A]+[B]
cout<<" Matriks [C]=[A]+[B]
:"<<endl;
for(br=1;br<=jml_br;br++)
{
for (kl=1;kl<=jml_kl;kl++)
{
c[br][kl]=a[br][kl]+b[br][kl];
cout<<setiosflags(ios::right)<<setw(10)<<c[br][kl];
}
cout<<endl;
}
cout<<endl<<endl;
//Pengurangan Matriks [A]-[B]
cout<<" Matriks
[D]=[A]-[B] :"<<endl;
for(br=1;br<=jml_br;br++)
{
for (kl=1;kl<=jml_kl;kl++)
{
c[br][kl]=a[br][kl]-b[br][kl];
cout<<setiosflags(ios::right)<<setw(10)<<c[br][kl];
}
cout<<endl;
}
cout<<endl;
puts("
--------------------------------------------------- ");
getch();
}
MENGHITUNG MATRIKS MENGGUNAKAN C++
Reviewed by Dwi Yuli Wibowo
on
October 08, 2015
Rating:
No comments:
Pembaca yang baik tinggalkan komentar yang baik