adesuryadi_

TAI 2

Apr 2nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include <iostream.h>
  2. #include <conio.h>
  3.  
  4. void main()
  5. {
  6. int b,k,s;
  7. int A[5][5],B[5][5],C[5][5];
  8.  
  9. //Matriks A
  10. for(b=0;b<3;b++)
  11. {
  12. for(k=0;k<3;k++)
  13. {
  14. cout<<" Matiks A Baris " <<(b+1)<<"."<<(k+1)<<" : ";
  15. cin>>A[b][k];
  16. } cout<<endl;
  17. }cout<<endl;
  18.  
  19. //Matriks B
  20. for(b=0;b<3;b++)
  21. {
  22. for(k=0;k<3;k++)
  23. {
  24. cout<<" Matiks B Baris " <<(b+1)<<"."<<(k+1)<<" : ";
  25. cin>>B[b][k];
  26. } cout<<endl;
  27. }
  28. clrscr();
  29.  
  30. //Rumus Perkalian
  31. for(b=0;b<3;b++)
  32. {
  33. for(k=0;k<3;k++)
  34. {
  35. C[b][k]=0;
  36. for(s=0;s<3;s++)
  37. {
  38. C[b][k]=A[b][s]*B[s][k]+ C[b][k];
  39. }
  40. }
  41. }
  42.  
  43. //cetak Matiks A
  44. cout<<" Matriks A \n";
  45. for(b=0;b<3;b++)
  46. {
  47. for(k=0;k<3;k++)
  48. {
  49. cout<<A[b][k]; cout<<"\t";
  50. } cout<<endl;
  51. }
  52.  
  53. //Cetak Matriks B
  54. cout<<" Matriks B \n";
  55. for(b=0;b<3;b++)
  56. {
  57. for(k=0;k<3;k++)
  58. {
  59. cout<<B[b][k]; cout<<"\t";
  60. } cout<<endl;
  61. }
  62.  
  63. //Cetak Matriks C
  64. cout<<"===========================\n";
  65. cout<<" Matriks C \n";
  66. cout<<"===========================\n";
  67. for(b=0;b<3;b++)
  68. {
  69. for(k=0;k<3;k++)
  70. {
  71. cout<<C[b][k]; cout<<"\t";
  72. } cout<<endl;
  73. }
  74.  
  75.  
  76. getch();
  77. }
Add Comment
Please, Sign In to add comment