Advertisement
seld1

Untitled

May 14th, 2021
728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. // test.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
  2. //
  3.  
  4. #include <iostream>
  5. using namespace std;
  6. int main()
  7. {
  8.     int buf_n=0;
  9.     int buf_m=0;
  10.     const int n = 5;
  11.     const int m = 5;
  12.     srand(time(0));
  13.     int Array[n][m];
  14.     while (buf_n != n) {
  15.        
  16.         while (buf_m!=m)
  17.         {
  18.             bool IsExitst = false;
  19.             int number = rand() % 60;
  20.             for (int i = 0; i <= buf_n; i++) {
  21.                 if (i!=buf_n) {
  22.                     for (int j = 0; j <= buf_m; j++) {
  23.                         if (Array[i][j] == number) {
  24.                             IsExitst = true;
  25.                             break;
  26.                         }
  27.                     }
  28.                 }
  29.                 else {
  30.                     for (int j = 0; j <= m; j++) {
  31.                         if (Array[i][j] == number) {
  32.                             IsExitst = true;
  33.                             break;
  34.                         }
  35.                     }
  36.                 }
  37.                 if (IsExitst)
  38.                      break;
  39.             }
  40.             if (!IsExitst) {
  41.                 Array[buf_n][buf_m] = number;
  42.                 buf_m++;
  43.             }
  44.  
  45.         }
  46.         buf_m=0;
  47.         buf_n++;
  48.     }
  49.     for (int i = 0; i < n; i++) {
  50.         for (int j = 0; j < m; j++) {
  51.             cout << Array[i][j] << "\t";
  52.         }
  53.         cout << "\n";
  54.     }
  55.    
  56. }
  57.  
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement