Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ALG08du.cpp: Definuje vstupní bod pro konzolovou aplikaci.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <random>
- #include <fstream>
- #include <string>
- using namespace std;
- const unsigned int N = 10;
- int main()
- {
- bool matrix[N][N];
- random_device rd;
- mt19937 mt(rd());
- uniform_int_distribution<int> dist(0, 1);
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < N; j++) {
- matrix[i][j] = dist(mt);
- cout << boolalpha << matrix[i][j] << " ";
- }
- cout << endl;
- }
- ofstream f;
- f.open("C:/Users/rnova/source/repos/ALG08du/coord.txt", ios::out);
- if (!f.is_open()) {
- cout << "Whops" << endl;
- return 0;
- }
- for (int i = 1; i < N-1; i++) {
- for (int j = 1; j < N-1; j++) {
- if (matrix[i - 1][j] == 1 && matrix[i][j - 1] == 0
- && ((matrix[i][j + 1] == 0 && matrix[i + 1][j] == 1)
- || (matrix[i][j + 1] == 1 && matrix[i + 1][j] == 0))) {
- f << "[" << i << "][" << j << "] ";
- }
- }
- }
- f.close();
- ifstream reader;
- reader.open("C:/Users/rnova/source/repos/ALG08du/coord.txt", ios::in);
- string s;
- getline(reader, s);
- cout << s << endl;
- reader.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement