Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- int main() {
- int i = 1;
- bool *currArray = new bool[5];
- for (int j=0;j<5;j++) currArray[j] = true;
- while (1) {
- int countTrueHere = 0;
- bool currentValue = false;
- bool *newArray = new bool[4*(i+1)+1];
- int currCount = 4*i + 1;
- int newCount = 4*(i+1)+1;
- for (int j=0;j<newCount;j++) {
- bool newValue = currentValue;
- if (j < currCount && currArray[j]) newValue = !newValue;
- if (j > 4 && currArray[j-5]) newValue = !newValue;
- currentValue = newArray[j] = newValue;
- if (currentValue) countTrueHere++;
- }
- i++;
- delete currArray;
- currArray = newArray;
- printf("f(%d) = %d\n",i,countTrueHere);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement