Advertisement
STANAANDREY

sume_partiale_matrici

Jun 12th, 2019
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. unsigned long a[100][100];
  4.  
  5. int main() {
  6.  
  7. unsigned long n,m,i,j,s[100][100];
  8. cout<<"n=";cin>>n;
  9. cout<<"m=";cin>>m;
  10. for (i=1;i<=n;i++)
  11. for (j=1;j<=m;j++)
  12. cin>>a[i][j];
  13.  
  14. //constr s
  15. for (i=1;i<=n;i++)
  16. for (j=1;j<=m;j++)
  17. s[i][j] = a[i][j] + s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
  18.  
  19. for (i=1;i<=n;i++) {
  20. for (j=1;j<=m;j++)
  21.  cout<<s[i][j]<<' ';
  22.  cout<<endl;
  23. }
  24.   return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement