PROFESSOR_AIH

N. Sum of a Matrix

Mar 22nd, 2023
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1. //           * * Bismillahir Rahmanir Rahim  * *
  2. // ************************@Author*******************************
  3. /*                    Asik Ifthaker Hamim                       */
  4. #include <bits/stdc++.h>
  5. #include<stdlib.h>
  6. using namespace std;
  7. typedef long long ll;
  8. typedef unsigned long long int ulli;
  9. typedef long long int lli;
  10. typedef unsigned long long ull;
  11. typedef vector<int> vi;
  12. typedef vector<ll> vl;
  13. typedef vector<string> vs;
  14. typedef pair<ll,ll> pr;
  15. #define pb push_back
  16. #define sz(n) n.size()
  17. #define vs(n) (int)n.size()
  18. #define pp pop_back
  19. #define sp(n) setprecision(n)
  20. const int MOD = 1000000007;
  21. #define ffor(a, b) for (int i = a; i <b; i++)
  22. #define frev(b, a) for (int i = b; i >= a; i--)
  23. #define PI (acos(-1.0))
  24. #define torad(x) ((x)*((2*acos(0))/180.0))
  25. #define todeg(x) ((x)*(180.0/(2*acos(0))))
  26. #define fixAngle(x) ((x)>1?1:(x)<-1?-1:(x))
  27. #define tan(a) tan(a)/(pi/180)
  28. #define sin(a) sin(a)/(pi/180)
  29. #define cos(a) cos(a)/(pi/180)
  30. #define inverse_sin(a) asin(a)/(pi/180)
  31. #define inverse_cos(a) acos(a)/(pi/180)
  32. #define inverse_tan(a) atan(a)/(pi/180)
  33. const int dr4[] = {0, 1, 0, -1};
  34. const int dc4[] = {1, 0, -1, 0};
  35. const int dr8[] = {0, 1, 1, 1, 0, -1, -1, -1};
  36. const int dc8[] = {1, 1, 0, -1, -1, -1, 0, 1};
  37. using namespace std;
  38. double neg_infinity(-std::numeric_limits<double>::infinity());
  39. int arr[10002],brr[10002],n,m;
  40. void sum(int idx)
  41. {
  42.     if(idx==(n*m)-1)
  43.     {
  44.         cout<<arr[idx]+brr[idx]<<endl;
  45.         return;
  46.     }
  47.     cout<<arr[idx]+brr[idx]<<" ";
  48.     if((idx+1)%(m)==0)
  49.     {
  50.         cout<<endl;
  51.     }
  52.     sum(idx+1);
  53. }
  54. int main()
  55. {
  56.     ios_base::sync_with_stdio(false);
  57.     cin.tie(0);
  58.     cout.tie(0);
  59.     cin>>n>>m;
  60.     for(int i=0; i<n*m; i++)
  61.     {
  62.  
  63.         cin>>arr[i];
  64.     }
  65.     for(int i=0; i<n*m; i++)
  66.     {
  67.         cin>>brr[i];
  68.     }
  69.     sum(0);
  70.  
  71. }
  72.  
Add Comment
Please, Sign In to add comment