Advertisement
STANAANDREY

parcur_diag_paralele

Jun 11th, 2019
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.   int N, m[101][101];
  6.   cin>>N;
  7.   for (int i = 1; i <= N; ++i)
  8.     for (int j = 1; j <= N; ++j)
  9.       cin>>m[i][j];
  10.  
  11.   for (int j = N; j >= 1; --j) {
  12.     int linie = 1, coloana = j;
  13.     while (linie <= N && coloana <= N) {
  14.       cout<<m[linie][coloana]<<' ';
  15.       ++linie;
  16.       ++coloana;
  17.     }
  18.     cout<<endl;
  19.   }
  20.   for (int i = 2; i <= N; ++i) {
  21.     int linie = i, coloana = 1;
  22.     while (linie <= N && coloana <= N) {
  23.       cout<<m[linie][coloana]<<' ';
  24.       ++linie;
  25.       ++coloana;
  26.     }
  27.     cout<<endl;
  28.   }
  29.   return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement