Advertisement
Guest User

SUCK A DICK BITCH

a guest
Nov 16th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include "pch.h"
  2. // Example program
  3. #include <iostream>
  4. #include <string>
  5. using namespace std;
  6. int main()
  7. {
  8.     freopen("input.txt", "r", stdin);
  9.     freopen("output.txt", "w", stdout);
  10.     const int val = -10000000;
  11.     int n, m; cin >> n >> m;
  12.     int max;
  13.     if (n > m) {
  14.         max = n;
  15.     }
  16.     else {
  17.         max = m;
  18.     }
  19.  
  20.     int **a = new int*[max + 1];
  21.     for (int i = 1; i <= max; i++) {
  22.         a[i] = new int[max + 1];
  23.     }
  24.     for (int i = 1; i <= max; i++) {
  25.         for (int j = 1; j <= max; j++) {
  26.             a[i][j] = val;
  27.         }
  28.     }
  29.     for (int i = 1; i <= n; i++) {
  30.         for (int j = 1; j <= m; j++) {
  31.             cin >> a[i][j];
  32.         }
  33.     }
  34.     for (int i = 1; i <= max; i++) {
  35.         for (int j = 1; j <= i; j++) {
  36.             if (a[i - j + 1][j] != val) {
  37.                 cout << a[i - j + 1][j] << " ";
  38.             }
  39.         }
  40.         cout << endl;
  41.     }
  42.     for (int j = 2; j <= max; j++) {
  43.         for (int i = max; i >= j; i--) {
  44.             if (a[i][max - i + j] != val) {
  45.                 cout << a[i][max - i + j] << " ";
  46.             }
  47.         }
  48.         cout << endl;
  49.     }
  50.  
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement