Advertisement
Guest User

Tugas_akhir

a guest
Mar 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8. int matA[3][3];
  9.  
  10.  
  11.  
  12. int matB[3][3];
  13. int matC[3][3];
  14. for(int i=0; i<3; i++){
  15. for(int j=0; j<3; j++){
  16. cout<<"Data Matriks A ["<<i+1<<"] ["<<j+1<<"] : ";
  17. cin>>matA[i][j];
  18. }
  19. }
  20.  
  21. cout<<"\n\n";
  22. cout<<"Matriks A : \n\n";
  23. cout<<"\t";
  24. for(int i=0;i<3;i++){
  25. for(int j=0;j<3;j++){
  26. cout<<matA[i][j]<<" ";
  27. }
  28. cout<<endl;
  29. cout<<"\t";
  30. }
  31.  
  32. cout<<endl;
  33. for(int i=0; i<3; i++){
  34. for(int j=0; j<3; j++){
  35. cout<<"Data Matriks B ["<<i+1<<"] ["<<j+1<<"] : ";
  36. cin>>matB[i][j];
  37. }
  38. }
  39.  
  40. cout<<"\n\n";
  41. cout<<"Matriks B : \n\n";
  42. cout<<"\t";
  43. for(int i=0;i<3;i++){
  44. for(int j=0;j<3;j++){
  45. cout<<matB[i][j]<<" ";
  46. }
  47. cout<<endl;
  48. cout<<"\t";
  49. }
  50.  
  51. cout<<endl;
  52. cout<<"Matriks A + Matriks B :"<<endl;
  53. for(int i=0; i<3; i++){
  54. for(int j=0; j<3; j++){
  55. matC[i][j] = matA[i][j]+matB[i][j];
  56. cout<<setw(8)<<matC[i][j];
  57. }
  58. cout<<endl;
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement