Advertisement
hopingsteam

Untitled

Apr 11th, 2020
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include    <iostream>
  2. #include    <fstream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream fin("bac.in");
  7.  
  8. int main()
  9. {
  10.     int n = 4, m = 5;
  11.     int mat[25][25];
  12.  
  13.     for(int i = 1; i <= n; i++)
  14.         mat[i][m] = 1;
  15.     for(int j = 1; j <= m; j++)
  16.         mat[n][j] = 1;
  17.  
  18.     for(int i = n - 1; i >= 1; i--)
  19.     {
  20.         for(int j = m - 1; j >= 1; j--)
  21.             mat[i][j] = (mat[i][j + 1] + mat[i + 1][j]) % 10;
  22.     }
  23.  
  24.     for(int i = 1; i <= n; i++)
  25.     {
  26.         for(int j = 1; j <= m; j++)
  27.             cout << mat[i][j] << " ";
  28.         cout << "\n";
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement