Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. //#include <windows.h>
  4.  
  5. using namespace std;
  6.  
  7. bool areSame(string part1[], string part2[], string part3[], string part4[]) {
  8.     for (int y = 0; y < 10; y++) {
  9.         for (int x = 0; x < 10; x++) {
  10.             char b = part1[y][x];
  11.             string a = "";
  12.             a += part2[y][x];
  13.             a += part3[y][x];
  14.             a += part4[y][x];
  15.            
  16.             for (char c : a) {
  17.                 if (c != b) return false;
  18.             }
  19.         }
  20.     }
  21.     return true;
  22. }
  23.  
  24. int main() {
  25.    
  26.  
  27.     ifstream dane("dane_obrazki.txt");
  28.     if (!dane.is_open()) {
  29.         return -1;
  30.     }
  31.    
  32.     int counter = 0;
  33.     for (int obrazIndex = 0; obrazIndex < 200; obrazIndex++) {
  34.        
  35.         //system("pause");
  36.         //system("cls");
  37.        
  38.         string part1[10], part2[10], part3[10], part4[10];
  39.         for (int i = 0; i < 10; i++) {
  40.             part1[i] = "";
  41.             part2[i] = "";
  42.             part3[i] = "";
  43.             part4[i] = "";
  44.         }
  45.        
  46.         for (int y = 0; y < 20; y++) {
  47.            
  48.             string row = "";
  49.             if (!(dane >> row)) {
  50.                 return -2;
  51.             }
  52.            
  53.             for (int x = 0; x < 20; x++) {
  54.                
  55.                 if ((x < 10)&&(y<10)) {
  56.                     // Part1
  57.                     part1[y] += row[x];
  58.                    
  59.                     //cout << row[x];
  60.                 } else if ((x < 10)&&(y >= 10)) {
  61.                     // Part3
  62.                     part3[y-10] += row[x];
  63.                    
  64.                     //cout << row[x];
  65.                 } else if ((x >= 10)&&(y >= 10)) {
  66.                     // Part4
  67.                     part4[y-10] += row[x];
  68.                    
  69.                     //cout << row[x];
  70.                 } else {
  71.                     // Part2
  72.                     part2[y] += row[x];
  73.                    
  74.                     //cout << row[x];
  75.                 }
  76.                
  77.                 //if (x == 9) cout << " ";
  78.                 //else if (x == 19) cout << endl;
  79.             }
  80.            
  81.             //if (y == 9) cout <<  endl;
  82.            
  83.             if (y == 19) {
  84.                 // Bity parzysto�ci kolumn
  85.                 if (!(dane >> row)) {
  86.                     return -3;
  87.                 }
  88.                 string pairs = row;
  89.             }
  90.         }
  91.        
  92.         //show(part1, part2, part3, part4);
  93.         if (areSame(part1, part2, part3, part4)) {
  94.             counter++;
  95.            
  96.             if (counter == 1) {
  97.                
  98.                 for (int y = 0; y < 10; y++) {
  99.                    
  100.                     for (int x = 0; x < 10; x++) {
  101.                         cout << part1[y][x];
  102.                         cout << part1[y][x];
  103.                     }
  104.                     cout << endl;
  105.                 }
  106.             }
  107.         }
  108.        
  109.         //cout << endl << "Licznik: " << counter << endl;
  110.     }
  111.    
  112.     cout << endl << "Wszystkich: " << counter << endl;
  113.    
  114.     dane.close();
  115.     return 0;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement