Advertisement
ProgramoBien

HR viernes

Feb 9th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define rep(i,j,n) for(int (i) = int (j); i < int (n); ++i)
  4.  
  5. const int N = 380;
  6. int t[N][N],a[N][N];
  7. int n, m, k;
  8.  
  9. void input(){
  10.     ios_base::sync_with_stdio(false);   cin.tie(0); cout.tie(0);
  11.     cin >> n >> m >> k;
  12.     rep(i,0,n) rep(j,0,m) cin >> t[i][j];
  13. }
  14.  
  15. void pra(){
  16.     rep(i,0,n){
  17.         rep(j,0,n){
  18.             cout << a[i][j];
  19.         } cout << endl;
  20.     } cout << endl;
  21. }
  22.  
  23. void solve(){
  24.     rep(i,0,n){
  25.         rep(j,0,m){
  26.             if(j == 0) a[i][j] = t[i][j];
  27.             else a[i][j] = t[i][j] + a[i][j-1];
  28.         }
  29.     }
  30.     rep(i,0,n) rep(j,0,m) a[i][j] += (i > 0) ? a[i-1][j] : 0;
  31.    
  32.     pra();
  33. }
  34.  
  35. int main() {
  36.     input();
  37.     solve();
  38.     // your code goes here
  39.      
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement