StoneHaos

misha_sr4

Jun 29th, 2020
1,512
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. const int mod = 100;
  9. int NUMS[mod];
  10.  
  11. int main(void) {
  12.     srand(time(NULL));
  13.  
  14.     int ans1 = 0, ans2 = -1;
  15.     int n, m;
  16.     cin >> n >> m;
  17.  
  18.     int **matrix = new int*[n];
  19.     for (int i = 0; i < n; i++) {
  20.         matrix[i] = new int[m];
  21.         for (int j = 0; j < m; j++) {
  22.             matrix[i][j] = rand() % mod;
  23.             cout << setw(4) << matrix[i][j] << " ";
  24.             NUMS[matrix[i][j]] ++;
  25.         }
  26.         cout << "\n";
  27.     }
  28.  
  29.     for (int i = 0; i < n; i++) {
  30.         bool nol = false;
  31.         for (int j = 0; j < m; j++) {
  32.             if (matrix[i][j] == 0)
  33.                 nol = true;
  34.         }
  35.         if (!nol)
  36.             ans1 ++;
  37.     }
  38.     cout << "1> " << ans1 <<endl;
  39.     for (int i = 0; i < mod; i++) {
  40.         if (NUMS[i] > 1)
  41.             ans2 = i;
  42.     }
  43.     if (ans2 == -1)
  44.         cout << "2> no answer" <<endl;
  45.     else
  46.         cout << "2> " << ans2 <<endl;
  47.  
  48.  
  49.     for (int i = 0; i < n; ++ i)
  50.         delete [] matrix[i];
  51.     delete [] matrix;
  52.     return 0;
  53. }
RAW Paste Data