SHARE
TWEET

lol

a guest May 20th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. int n=3;
  4. using namespace std;
  5.  
  6. void printMatrix(int tmp[][n]){
  7.         for(int i = 0; i < n; i++){
  8.                 cout << "\n";
  9.                 for(int j = 0; j < n; j++){
  10.                         cout << tmp[i][j] << " ";
  11.                 }
  12.         }
  13.         cout << "\n";
  14. }
  15.  
  16. void fillMatrix(int tmp[][n]){
  17.         for(int i = 0; i < n; i++){
  18.                 for(int j = 0; j < n; j++){
  19.                         cout << "inserire un numero: ";
  20.                         cin >> matrice[i][j];
  21.                 }
  22.         }
  23. }
  24.  
  25. void sommaMatrix(int a[][n],int b[][n]){
  26.     int c[n][n];
  27.     for(int i = 0; i < n; i++){
  28.         for(int j = 0; j < n; j++){
  29.             c[i][j]=a[i][j]+b[i][j];
  30.         }
  31.     }
  32.     printMatrix[c];
  33. }
  34.  
  35. void prodottoMatrix(int a[][n],int b[][n]){
  36.     int d[n][n];
  37.     for(int i = 0; i < n; i++){
  38.         for(int j = 0; j < n; j++){
  39.             d[i][j]=a[i][j]*b[i][j];
  40.         }
  41.     }
  42.     printMatrix[d];
  43. }
  44.  
  45.  
  46. int main(){
  47.     int matriceA[n][n];
  48.     int matriceB[n][n];
  49.     fillMatrix(matriceA);
  50.     printMatrix(matriceA);
  51.     fillMatrix(matriceB);
  52.     printMatrix(matriceB);
  53.     sommaMatrix(matriceA,matriceB);
  54.     prodottoMatrix(matriceA,matriceB);
  55.    
  56.  
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top