Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int n=3;
- using namespace std;
- void printMatrix(int tmp[][n]){
- for(int i = 0; i < n; i++){
- cout << "\n";
- for(int j = 0; j < n; j++){
- cout << tmp[i][j] << " ";
- }
- }
- cout << "\n";
- }
- void fillMatrix(int tmp[][n]){
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- cout << "inserire un numero: ";
- cin >> matrice[i][j];
- }
- }
- }
- void sommaMatrix(int a[][n],int b[][n]){
- int c[n][n];
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- c[i][j]=a[i][j]+b[i][j];
- }
- }
- printMatrix[c];
- }
- void prodottoMatrix(int a[][n],int b[][n]){
- int d[n][n];
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- d[i][j]=a[i][j]*b[i][j];
- }
- }
- printMatrix[d];
- }
- int main(){
- int matriceA[n][n];
- int matriceB[n][n];
- fillMatrix(matriceA);
- printMatrix(matriceA);
- fillMatrix(matriceB);
- printMatrix(matriceB);
- sommaMatrix(matriceA,matriceB);
- prodottoMatrix(matriceA,matriceB);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement