Advertisement
Guest User

PE588

a guest
Jun 25th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <cstdio>
  2. #include <iostream>
  3.  
  4. int main() {
  5.  
  6.     int i = 1;
  7.     bool *currArray = new bool[5];
  8.     for (int j=0;j<5;j++) currArray[j] = true;
  9.     while (1) {
  10.         int countTrueHere = 0;
  11.         bool currentValue = false;
  12.         bool *newArray = new bool[4*(i+1)+1];
  13.         int currCount = 4*i + 1;
  14.         int newCount = 4*(i+1)+1;
  15.         for (int j=0;j<newCount;j++) {
  16.             bool newValue = currentValue;
  17.             if (j < currCount && currArray[j]) newValue = !newValue;
  18.             if (j > 4 && currArray[j-5]) newValue = !newValue;
  19.  
  20.             currentValue = newArray[j] = newValue;
  21.             if (currentValue) countTrueHere++;
  22.         }
  23.  
  24.         i++;
  25.         delete currArray;
  26.         currArray = newArray;
  27.         printf("f(%d) = %d\n",i,countTrueHere);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement