Pages

Kamis, 03 Mei 2012

Program

Contoh Program Penjumlahan Matriks..

#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 << "Operasi Penjumlahan Matrix\n";
  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();
}

1 komentar:

nurulapriyanii mengatakan...

kawan, jangan lupa ya memasang RSS Feed BAAK dan RSS Feed Studentsite ya. Cara teknisnya bisa dilihat di http://hanum.staff.gunadarma.ac.id/Downloads/files/30949/RSS+Feed+BAAK.pdf & http://hanum.staff.gunadarma.ac.id/Downloads/files/30947/RSS+Feed+Studentsite+Pada+Blogspot.pdf

Poskan Komentar

 

(c)2009 "Get Information". Based in Wordpress by wpthemesfree Created by Templates for Blogger