Skip to content

Instantly share code, notes, and snippets.

@Firemoon777
Created April 5, 2017 22:00
Show Gist options
  • Save Firemoon777/3216be405f38e80cc243495c84f5cf43 to your computer and use it in GitHub Desktop.
Save Firemoon777/3216be405f38e80cc243495c84f5cf43 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main() {
void *array[] = {NULL, &&state1, &&state2, &&state3, &&state4, &&state5, &&state6, &&state7};
goto *array[1];
char c;
return 1;
state1:
if(getchar() == 'a') {
goto *array[2];
}
printf("No match\n"); return 0;
state2:
c = getchar();
if(c == 'a') {
goto *array[3];
}
if(c == 'b') {
goto *array[4];
}
printf("No match\n"); return 0;
state3:
if(getchar() == 'b') {
goto *array[5];
}
printf("No match\n"); return 0;
state4:
if(getchar() == 'b') {
goto *array[6];
}
printf("No match\n"); return 0;
state5:
c = getchar();
if(c == 'a') {
goto *array[3];
}
if(c == 'b') {
goto *array[4];
}
printf("No match\n"); return 0;
state6:
c = getchar();
if(c == '\n') {
printf("Match!\n");
return 0;
}
if(c == 'c') {
goto *array[7];
}
printf("No match\n"); return 0;
state7:
if(getchar() == 'b') {
goto *array[6];
}
printf("No match\n"); return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment