Advertisement
Guest User

Untitled

a guest
Apr 10th, 2020
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.51 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3.                             Online C Compiler.
  4.                 Code, Compile, Run and Debug C program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <stdio.h>
  10.  
  11. int main()
  12. {
  13.     int matriceA[100][100], matriceB[100][100],matriceRez[100][100];
  14.     int i,j,totalSum=0,n,m;
  15.    
  16.     printf("Numarul de linii:\n");
  17.     scanf("%d", &n);
  18.     printf("Numarul de coloane:\n");
  19.     scanf("%d", &m);
  20.     printf("matriceA:\n");
  21.     for(i=0;i<n;i++)
  22.     {
  23.         for(j=0;j<m;j++)
  24.         {
  25.             printf("introduceti valoare pentru pozitiile: %d %d \n", i,j);
  26.             scanf("%d", &matriceA[i][j]);
  27.         }
  28.     }
  29.     printf("matriceB:\n");
  30.     for(i=0;i<n;i++)
  31.     {
  32.         for(j=0;j<m;j++)
  33.         {
  34.             printf("introduceti valoare pentru pozitiile: %d %d \n", i,j);
  35.             scanf("%d", &matriceB[i][j]);
  36.         }
  37.     }
  38.    
  39.    
  40.     for(i=0;i<n;i++)
  41.     {
  42.         for(j=0;j<m;j++)
  43.         {
  44.             matriceRez[i][j] = matriceA[i][j] + matriceB[i][j];
  45.             totalSum += matriceRez[i][j];
  46.         }
  47.     }
  48.    
  49.    
  50.     printf("Matrice rezultat \n");
  51.     for(i=0;i<n;i++)
  52.     {
  53.         for(j=0;j<m;j++)
  54.         {
  55.             printf("%d ", matriceRez[i][j]);
  56.         }
  57.         printf("\n");
  58.     }
  59.     printf("Suma totala: %d", totalSum);
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement