AndreyKlipikov

[Segrey] Prog. Lab7. N18

Dec 25th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <time.h>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     const int n = 4;
  9.     int a[n][n], b[n * n / 2], k = 0;
  10.     srand(time(NULL));
  11.     for (int i = 0; i < n; i++) {
  12.             for(int j = 0; j < n; j++) {
  13.                     a[i][j] = rand() % 10 - 2;
  14.                     cout << a[i][j] << " ";
  15.             }
  16.             cout << endl;
  17.     }
  18.  
  19.     cout << endl;
  20.  
  21.     for (int i = 0; i < n; i++) {
  22.             for(int j = 0; j < n; j++) {
  23.                     if (i < j && a[i][j] > 0)
  24.                         b[k++] = a[i][j];
  25.             }
  26.     }
  27.  
  28.     for(int i = 0; i < k; i++)
  29.         cout << b[i] << " ";
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment