#include<iostream.h> #include<conio.h> main() { int pilihan; cout<<"=======Program Penghitung Bilangan Matrik=======\n"; cout<<"*MENU : \n"; cout<<"[1] Perkalian\n"; cout<<"[2] Penjumlahan\n"; cout<<"[3] Pengurangan\n"; cout<<"Masukkan Pilihan Anda = "; cin>>pilihan; switch(pilihan) { int a[10][10],b[10][10],c[10][10]; int CC,i,j,k; case 1 :system("cls"); cout<<"=====Perkalian Matrik=====\n"; cout<<endl<<" Elemen matriks A : "<<endl; for (i=1; i<=2;i++){ for (j=1;j<=2;j++){ cout<<" Elemen matrik A baris ke-"<<i<<" kolom ke-"<<j<<": "; cin>>a[i][j]; } } cout<<endl<<" Elemen matriks B : "<<endl; for (i=1; i<=2;i++){ for (j=1;j<=2;j++){ cout<<" Elemen matrik B baris ke-"<<i<<" kolom ke-"<<j<<": "; cin>>b[i][j]; } } cout<<endl; for (i=1;i<=2;i++){ for (j=1;j<=2;j++){ c[i][j]=0; for (k=1;k<=2;k++){ CC=a[i][k]*b[k][j]; c[i][j]=c[i][j]+CC; } } } cout<<" Element matriks C [hasil] : "<<endl; for (i=1;i<=2;i++){ for (j=1;j<=2;j++){ cout<<" "<<c[i][j]; } cout<<endl; } break; case 2 : system("cls"); cout<<"=====Penjumlahan Matrik=====\n"; cout<<endl<<" Elemen matriks A : "<<endl; for (i=1; i<=2;i++){ for (j=1;j<=2;j++){ cout<<" Elemen matrik A baris ke-"<<i<<" kolom ke-"<<j<<": "; cin>>a[i][j]; } } cout<<endl<<" Elemen matriks B : "<<endl; for (i=1; i<=2;i++){ for (j=1;j<=2;j++){ cout<<" Elemen matrik B baris ke-"<<i<<" kolom ke-"<<j<<": "; cin>>b[i][j]; } } cout<<endl; for (i=1;i<=2;i++){ for (j=1;j<=2;j++){ c[i][j]=0; for (k=1;k<=2;k++){ CC=a[i][k]+b[k][j]; c[i][j]=c[i][j]+CC; } } } cout<<" Element matriks C [hasil] : "<<endl; for (i=1;i<=2;i++){ for (j=1;j<=2;j++){ cout<<" "<<c[i][j]; } cout<<endl; } break; case 3 :system("cls"); cout<<"=====Pengurangan Matrik=====\n"; cout<<endl<<" Elemen matriks A : "<<endl; for (i=1; i<=2;i++){ for (j=1;j<=2;j++){ cout<<" Elemen matrik A baris ke-"<<i<<" kolom ke-"<<j<<": "; cin>>a[i][j]; } } cout<<endl<<" Elemen matriks B : "<<endl; for (i=1; i<=2;i++){ for (j=1;j<=2;j++){ cout<<" Elemen matrik B baris ke-"<<i<<" kolom ke-"<<j<<": "; cin>>b[i][j]; } } cout<<endl; for (i=1;i<=2;i++){ for (j=1;j<=2;j++){ c[i][j]=0; for (k=1;k<=2;k++){ CC=a[i][k]-b[k][j]; c[i][j]=c[i][j]+CC; } } } cout<<" Element matriks C [hasil] : "<<endl; for (i=1;i<=2;i++){ for (j=1;j<=2;j++){ cout<<" "<<c[i][j]; } cout<<endl; } break; } getch(); }
Monday, November 11, 2013
Program Operasi Perhitungan Matrik (Perkalian, Penjumlahan, Pengurangan)
Labels:
Algoritma dan Pemrograman
Subscribe to:
Post Comments (Atom)
makasih gan
ReplyDelete