Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main() {
- ifstream dane("dane_obrazki.txt");
- if (!dane.is_open()) {
- return -1;
- }
- int good = 0, fixable = 0, completlyDestroied = 0;
- for (int obrazIndex = 0; obrazIndex < 200; obrazIndex++) {
- bool obraz[20][20];
- int xErrors = 0, yErrors = 0;
- for (int y = 0; y < 20; y++) {
- int ones = 0;
- string row = "";
- if (!(dane >> row)) {
- return -2;
- }
- for (int x = 0; x < 20; x++) {
- obraz[y][x] = row[x] - '0';
- if (obraz[y][x]) ones++;
- if (x == 19) {
- // Bit parzysto?ci
- bool b = row[20] - '0';
- if ((ones%2==0) && b) {
- xErrors++;
- }
- //cout << row << endl << endl;
- //cout << endl << "ones: "<< ones << " b: " << row[20] << endl;
- }
- }
- if (y == 19) {
- // Bity parzysto?ci kolumn
- if (!(dane >> row)) {
- return -3;
- }
- //cout << row << endl << endl;
- string s = row;
- for (int j = 2; j < s.length(); j++) {
- bool b = s[j] - '0';
- int c1 = 0;
- for (int i = 0; i < 20; i++) {
- //cout << obraz[i][j] << endl;
- if (obraz[i][j]) c1++;
- }
- if ((c1%2==0) && b) {
- yErrors++;
- }
- //cout << endl << c1 << " " << b << endl;
- //break;
- }
- }
- }
- if ((xErrors > 1)&&(yErrors > 1)) completlyDestroied++;
- else if ((xErrors <= 1)&&(yErrors <= 1)) fixable++;
- else good++;
- //break;
- }
- cout << good << endl;
- cout << fixable << endl;
- cout << completlyDestroied << endl;
- dane.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement