YaK:: brainf.c [Changes]   [Calendar]   [Search]   [Index]   [PhotoTags]   
[mega_changes]
[photos]

brainf.c

#include <stdio.h>

main() {
        printf("#include <stdio.h>\n");
        printf("int t[30000];\nint p;\nmain() {\n");
        while (1) {
                int c = getchar();
                if (c == EOF) break;

                switch (c) {
                case '+': printf("++t[p];\n"); break;
                case '-': printf("--t[p];\n"); break;
                case '>': printf("++p;\n"); break;
                case '<': printf("--p;\n"); break;
                case '.': printf("printf(\"%%d\\n\",t[p]);\n"); break;
                case '[': printf("while (t[p]) {\n"); break;
                case ']': printf("}\n"); break;
                }
        }
        printf("int i; for (i=0; i < 10; i++) { printf(\" %%d \", t[i]); }\n");
        printf("printf(\"\\n\"); \n}\n");
        return 0;
}
(unless otherwise marked) Copyright 2002-2014 YakPeople. All rights reserved.
(last modified 2013-11-07)       [Login]
(No back references.)