Advertisement
totobac

Untitled

Jan 5th, 2021
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n,columns,rows;
  6.     cout << "Enter the number of users: ";
  7.     cin >> n;
  8.     int* array = new int[n];
  9.     for (size_t i = 0; i < n; i++)
  10.     {
  11.         do
  12.         {
  13.             cout << "Enter the person number " << i + 1 << "'s last 4 digits: ";
  14.             cin >> array[i];
  15.         } while (array[i] <1000 || array[i] > 9999);
  16.    
  17.     }
  18.  
  19.     int matrix[100][100] = { 0 };
  20.     cout << "Enter the number of columns: ";
  21.     cin >> columns;
  22.     cout << "Enter the number of rows: ";
  23.     cin >> rows;
  24.  
  25.  
  26.     int counter = 0;
  27.     for (size_t i = 0; i < rows; i++)
  28.     {
  29.         for (size_t j = 0; j < columns; j++)
  30.         {
  31.             if (counter < n)
  32.             {
  33.                 matrix[i][j] = array[counter];
  34.                 counter++;
  35.             }
  36.         }
  37.     }
  38.    
  39.     for (size_t i = 0; i < rows; i++)
  40.     {
  41.         cout << endl;
  42.         for (size_t j = 0; j < columns; j++)
  43.         {
  44.             if (matrix[i][j] == 0)
  45.                 cout << "000";
  46.             cout << matrix[i][j] << " ";
  47.         }
  48.     }
  49.     cout << endl;
  50.  
  51.     bool isIdentical = false;
  52.     for (size_t i = 0; i < columns; i++)
  53.     {
  54.         for (size_t j = 0; j < rows; j++)
  55.         {
  56.             isIdentical = false;
  57.             int countingRows = 1;
  58.             while (countingRows <= rows - j)
  59.             {
  60.                 if (matrix[j][i] != 0 && matrix[j][i] == matrix[j][countingRows])
  61.                     {
  62.                         isIdentical = true;
  63.                         break;
  64.                         cout << "aaa";
  65.                     }
  66.  
  67.                 countingRows++;
  68.             }
  69.            
  70.            
  71.         }
  72.         cout << isIdentical << "    ";
  73.     }
  74.     delete[] array;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement