Advertisement
fabis_sparks

ver21

Apr 3rd, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. // polina2-1.cpp: определяет точку входа для консольного приложения.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6.  
  7.  
  8. int main()
  9. {
  10.     using namespace std;
  11.     const int colCount = 5;
  12.     const int rowCount = 5;
  13.  
  14.     int mass[colCount][rowCount] = {
  15.         { 1, 1, 1, 1, 1 },
  16.         { 2, 2, 2, 2, 2 },
  17.         { 3, 3, 3, 3, 3 },
  18.         { 1, 1, 1, 1, 1 },
  19.         { 5, 5, 5, 5, 5 },
  20.     };
  21.  
  22.     int resCount = 0;
  23.     int result[colCount] = { -1, -1, -1, -1, -1 };
  24.  
  25.  
  26.  
  27.  
  28.     for (int i = 0; i < colCount; i++)
  29.     {
  30.         for (int j = 0; j < rowCount; j++)
  31.         {
  32.             cout << mass[i][j] << ", ";
  33.         }
  34.         cout << endl;
  35.     }
  36.     cout << "------------" << endl;
  37.  
  38.     for (int i = 0; i < colCount; i++)
  39.     {
  40.         bool found = false;
  41.  
  42.         for (int j = 0; j < rowCount; j++)
  43.         {
  44.             for (int r = 0; r < resCount; r++)
  45.             {
  46.                 if (!memcmp(mass[i], mass[result[r]], rowCount * sizeof(int)))
  47.                 {
  48.                     found = true;
  49.                     break;
  50.                 }
  51.             }
  52.             if (found) break;
  53.         }
  54.  
  55.         if (!found)
  56.         {
  57.             result[resCount] = i;
  58.             resCount++;
  59.         }
  60.     }
  61.  
  62.     for (int i = 0; i < resCount; i++)
  63.     {
  64.         cout << result[i] << ", ";
  65.     }
  66.     cout << endl << "------------" << endl;
  67.  
  68.     for (int i = 0; i < resCount; i++)
  69.     {
  70.         for (int j = 0; j < rowCount; j++)
  71.         {
  72.             cout << mass[result[i]][j];
  73.         }
  74.         cout << endl;
  75.     }
  76.  
  77.  
  78.     system("pause");
  79.     return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement