Skip to content

Instantly share code, notes, and snippets.

@rgrig
Created May 5, 2016 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgrig/ac3c99bfc45db6a7855650d481c8fb80 to your computer and use it in GitHub Desktop.
Save rgrig/ac3c99bfc45db6a7855650d481c8fb80 to your computer and use it in GitHub Desktop.
include <stdio.h>
int main() {
const int n = 200;
int data[n];
data[0]=0; data[1]=2;
int i, j;
i = j = 0;
int state = 0;
while (j < n) {
printf("%d\n",data[j]);
if (state == 0) {
if (data[j] == 0) {
data[j] = 1;
state = 1;
} else {
data[j] = 0;
}
}
if (data[++j] == 2) {
if (state == 0) {data[j++] = 1; data[j] = 2;}
j = 0;
state = 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment