-
-
Save st98/7809548 to your computer and use it in GitHub Desktop.
Brainf*ckのC実装です。雑です。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/types.h> | |
#define G ptr++; | |
#define L ptr--; | |
#define P (*ptr)++; | |
#define M (*ptr)--; | |
#define D putchar(*ptr); | |
#define C *ptr=getchar(); | |
#define B while(*ptr){ | |
#define T } | |
int main(void) { | |
u_char mem[30000] = {0}; | |
u_char *ptr = mem; | |
P P P P P P P P P B G P P P P P P P P G P P P P P P P P P P P G P P P P P L L L M T G D G P P D P P P P P P P D D P P P D G M D M M M M M M M M M M M M D L P P P P P P P P D M M M M M M M M D P P P D M M M M M M D M M M M M M M M D G P D | |
return EXIT_SUCCESS; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# "+++++[-]" -> "P P P P P B M T " | |
my $input = <STDIN>; | |
$input =~ tr/><+\-.,[]/GLPMDCBT/; | |
$input =~ s/(.)/\1 /g; | |
print $input; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment