Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- //#include <windows.h>
- using namespace std;
- bool areSame(string part1[], string part2[], string part3[], string part4[]) {
- for (int y = 0; y < 10; y++) {
- for (int x = 0; x < 10; x++) {
- char b = part1[y][x];
- string a = "";
- a += part2[y][x];
- a += part3[y][x];
- a += part4[y][x];
- for (char c : a) {
- if (c != b) return false;
- }
- }
- }
- return true;
- }
- int main() {
- ifstream dane("dane_obrazki.txt");
- if (!dane.is_open()) {
- return -1;
- }
- int counter = 0;
- for (int obrazIndex = 0; obrazIndex < 200; obrazIndex++) {
- //system("pause");
- //system("cls");
- string part1[10], part2[10], part3[10], part4[10];
- for (int i = 0; i < 10; i++) {
- part1[i] = "";
- part2[i] = "";
- part3[i] = "";
- part4[i] = "";
- }
- for (int y = 0; y < 20; y++) {
- string row = "";
- if (!(dane >> row)) {
- return -2;
- }
- for (int x = 0; x < 20; x++) {
- if ((x < 10)&&(y<10)) {
- // Part1
- part1[y] += row[x];
- //cout << row[x];
- } else if ((x < 10)&&(y >= 10)) {
- // Part3
- part3[y-10] += row[x];
- //cout << row[x];
- } else if ((x >= 10)&&(y >= 10)) {
- // Part4
- part4[y-10] += row[x];
- //cout << row[x];
- } else {
- // Part2
- part2[y] += row[x];
- //cout << row[x];
- }
- //if (x == 9) cout << " ";
- //else if (x == 19) cout << endl;
- }
- //if (y == 9) cout << endl;
- if (y == 19) {
- // Bity parzysto�ci kolumn
- if (!(dane >> row)) {
- return -3;
- }
- string pairs = row;
- }
- }
- //show(part1, part2, part3, part4);
- if (areSame(part1, part2, part3, part4)) {
- counter++;
- if (counter == 1) {
- for (int y = 0; y < 10; y++) {
- for (int x = 0; x < 10; x++) {
- cout << part1[y][x];
- cout << part1[y][x];
- }
- cout << endl;
- }
- }
- }
- //cout << endl << "Licznik: " << counter << endl;
- }
- cout << endl << "Wszystkich: " << counter << endl;
- dane.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement