Advertisement
Guest User

Untitled

a guest
May 19th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. class GoF {
  8. private:
  9.     int neighbors;
  10.     int pixel[10][10] = {
  11.         { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
  12.         { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 },
  13.         { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  14.         { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  15.         { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  16.         { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  17.         { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  18.         { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  19.         { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  20.         { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  21.     };
  22.     int i1;
  23. public:
  24.     void Start_G(int n)
  25.     {
  26.         cout << 'f' ;
  27.         for (int i1 = 0; i1 <= n; i1++)
  28.         {
  29.             for (int i = 0; i <= 9; i++)
  30.             {
  31.                 for (int j = 0; j <= 9; j++)
  32.                 {
  33.                     neighbors = (
  34.                         pixel[i - 1][j - 1] +
  35.                         pixel[i - 1][j] +
  36.                         pixel[i - 1][j + 1] +
  37.                         pixel[i][j + 1] +
  38.                         pixel[i][j - 1] +
  39.                         pixel[i + 1][j + 1] +
  40.                         pixel[i + 1][j] +
  41.                         pixel[i + 1][j - 1]
  42.                         );
  43.                     if (pixel[i][j] == 0) {
  44.                         if (neighbors == 3) {
  45.                             pixel[i][j] = 1;
  46.                         }
  47.                     }
  48.                     else {
  49.                         if (neighbors != 3) {
  50.                             pixel[i][j] = 0;
  51.                         }
  52.                     }
  53.                     cout << pixel[i][j] << ' ';
  54.                 }
  55.                 cout << ' ' << endl;
  56.             }
  57.         }
  58.    
  59.     }
  60. };
  61.  
  62. int main() {
  63.     int n;
  64.     cin >> n;
  65.     GoF F;
  66.     F.Start_G(n);
  67.     system("pause");
  68.     return 0;
  69. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement