Tuesday, December 24, 2019

Logika & Algoritma Tugas Pertemuan 9

SEMESTER 1
LOGIKA & ALGORITMA
TUGAS TELOMPOK PERTEMUAN 9

# KELOMPOK SILENT TEAM #
1. HARIS SYAEFUL AMRI      [NIM : 13190183]
2. PATAR SAMUEL                 [NIM : 13190497]
3. IKHWAN HAFIZH                [NIM : 13190090]
4. MULYANSYAH YUSUF       [NIM : 13190088]
5. SOLIKIN                              [NIM : 13190515]
KELAS           : 13.1B.07
JURUSAN      : TEKNIK KOMPUTER

Buatlah program dengan menggunakan C++

1. Penjumlahan dua buah matriks
2. Pengurangan dua buah matriks
    Ket :
    • Masing-masing kelompok dapat memilih salah satu dari program di atas.
    • Listing program & output dicetak
    • Nama, Nim dan Kelas dicetak di listing program

1. Program Penjumlahan dua buah matriks

Program Menggunakan Borland c++ 5.02
Input Script :
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
int i, j, baris, kolom, m1[10][10], m2[10][10], hasil[10][10];
void main()
{
  clrscr();
  cout<<"       # KELOMPOK SILENT TEAM # "<<endl;
  cout<<" ===================================="<<endl;
  cout<<" |NO| NAMA               | NIM      |"<<endl;
  cout<<" ===================================="<<endl;
  cout<<" |1 | HARIS SYAEFUL AMRI | 13190183 |"<<endl;
  cout<<" |2 | PATAR SAMUEL       | 13190497 |"<<endl;
  cout<<" |3 | IKHWAN HAFIZH      | 13190090 |"<<endl;
  cout<<" |4 | MULYANSYAH YUSUF   | 13190088 |"<<endl;
  cout<<" |5 | SOLIKIN            | 13190515 |"<<endl;
  cout<<" ===================================="<<endl;
  cout<<" KELAS        : 13.1B.07 "<<endl;
  cout<<" JURUSAN      : TEKNIK KOMPUTER "<<endl;
  cout<<" TAHUN AJARAN : 2019/2020 "<<endl;
  cout<<endl;
  cout << "=================================="<<endl;
  cout << "Operasi Penjumlahan Matrix\n";
  cout << "=================================="<<endl;
  do
  {
   cout << "Jumlah Baris = "; cin>>baris;
   cout << "Jumlah Kolom = "; cin>>kolom;
  }
  while((baris>10)||(kolom>10));
/*  do
  while(kolom>10);*/
  cout << "\nMatrix A" << endl;
  for(i=0;i<baris;i++)
   for(j=0;j<kolom;j++)
    {
     cout <<"data [" << i << "," << j << "] = ";
     cin>>m1[i][j];
    }
  cout << "\nMatrix B" << endl;
  for(i=0;i<baris;i++)
   for(j=0;j<kolom;j++)
    {
     cout <<"data [" << i << "," << j << "] = ";
     cin>>m2[i][j];
    }
  for(i=0; i<baris;i++)
    for(j=0; j<kolom; j++)
      hasil[i][j] = m1[i][j] + m2[i][j];
  cout << "\nHasilnya..." << endl;
  cout << "Matrix A  +  Matrix B  =  Matrix C";
  for(i=0; i< baris; i++)
   {
    cout<<'\n';
    for(j=0; j<kolom; j++)
     cout << setw(4) << m1[i][j];
     cout << "     ";
    for(j=0; j<kolom; j++)
     cout << setw(4) << m2[i][j];
     cout << "     ";
    for(j=0; j<kolom; j++)
     cout << setw(4) << hasil[i][j];
    cout << endl;
   }

  getch();

Output Program :























2. Program Pengurangan dua buah matriks

Program Menggunakan Borland c++ 5.02
Input Script :
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
int i, j, baris, kolom, m1[10][10], m2[10][10], hasil[10][10];
void main()
{
  clrscr();
  cout<<"       # KELOMPOK SILENT TEAM # "<<endl;
  cout<<" ===================================="<<endl;
  cout<<" |NO| NAMA               | NIM      |"<<endl;
  cout<<" ===================================="<<endl;
  cout<<" |1 | HARIS SYAEFUL AMRI | 13190183 |"<<endl;
  cout<<" |2 | PATAR SAMUEL       | 13190497 |"<<endl;
  cout<<" |3 | IKHWAN HAFIZH      | 13190090 |"<<endl;
  cout<<" |4 | MULYANSYAH YUSUF   | 13190088 |"<<endl;
  cout<<" |5 | SOLIKIN            | 13190515 |"<<endl;
  cout<<" ===================================="<<endl;
  cout<<" KELAS        : 13.1B.07 "<<endl;
  cout<<" JURUSAN      : TEKNIK KOMPUTER "<<endl;
  cout<<" TAHUN AJARAN : 2019/2020 "<<endl;
  cout<<endl;
  cout << "=================================="<<endl;
  cout << "Operasi Pengurangan Matrix\n";
  cout << "=================================="<<endl;
  do
  {
   cout << "Jumlah Baris = "; cin>>baris;
   cout << "Jumlah Kolom = "; cin>>kolom;
  }
  while((baris>10)||(kolom>10));
/*  do
  while(kolom>10);*/
  cout << "\nMatrix A" << endl;
  for(i=0;i<baris;i++)
   for(j=0;j<kolom;j++)
    {
     cout <<"data [" << i << "," << j << "] = ";
     cin>>m1[i][j];
    }
  cout << "\nMatrix B" << endl;
  for(i=0;i<baris;i++)
   for(j=0;j<kolom;j++)
    {
     cout <<"data [" << i << "," << j << "] = ";
     cin>>m2[i][j];
    }
  for(i=0; i<baris;i++)
    for(j=0; j<kolom; j++)
      hasil[i][j] = m1[i][j] - m2[i][j];
  cout << "\nHasilnya..." << endl;
  cout << "Matrix A  -  Matrix B  =  Matrix C";
  for(i=0; i< baris; i++)
   {
    cout<<'\n';
    for(j=0; j<kolom; j++)
     cout << setw(4) << m1[i][j];
     cout << "     ";
    for(j=0; j<kolom; j++)
     cout << setw(4) << m2[i][j];
     cout << "     ";
    for(j=0; j<kolom; j++)
     cout << setw(4) << hasil[i][j];
    cout << endl;
   }
  getch();

}

Output Program :





No comments:

Post a Comment