/阅读这样的代码就像在强奸你的大脑
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
#include<string.h>
char br[10000];
int main()
{
char *eip = br;
printf("请输入想解密的brainfuck代码\n");
scanf("%s",br);
printf("\n解密得到的flag\n\n");
char *mem = (char*)malloc(100);
char *ptr = mem;
bool isright = true;
while(*eip != 0)
{
if(*eip == '[')
{
while(*eip!=0 && *eip!=']')
++eip;
if(*eip == 0)
isright = false;
}
else if(*eip == ']')
isright = false;
if(!isright)
{
printf("The brainfuck code has some wrong!\n");
return 0;
}
++eip;
}
memset(ptr,0,100);
eip = br;
do
{
switch(*eip)
{
case '>':
++ptr;
break;
case '<':
--ptr;
break;
case '+':
++*ptr;
break;
case '-':
--*ptr;
break;
case '.':
putchar(*ptr);
break;
case ',':
*ptr = getchar();
break;
case '[':
if(*ptr == 0)
{
do
{
++eip;
}while(*eip!=']');
}
break;
case ']':
if(*ptr != 0)
{
do
{
--eip;
}while(*eip!='[');
}
break;
}
if( (ptr-mem)>100)
{
printf("Stack overflow!\n");
break;
}
++eip;
}while(*eip!=0);
free(mem);
return 0;
}