448 :
デフォルトの名無しさん:
はぁ、、、7行ではとてもとても…(´Д`)
とんでもない行数になっちまいました。
//----------------------------------------------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define sc strncmp
static int b[65536],r,m;static char l[100][80],c[80];
char*sk(char*s){char*p;for(p=s;*p==' ';p++);return p;}int ad(char*s){short*i;i=
s;return*i;}int is(char*s){int z;if((*s>='0'&&*s<='9')||*s=='-')z=atoi(s);else
z=b[ad(s)];return z;}cmd(char*s){int i,f,g;if(*s)if(sc(s,"GOTO ",5)==0){r=is(sk
(s+5))-1;}else if(sc(s,"PUT ",4)==0){printf("%d.",is(sk(s+4)));}else if(sc(s,
"? ",2)==0){f=0;if(s[strlen(s)-1]==';'){f=1;s[strlen(s)-1]=0;}printf("%s",s+2);
if(f)printf("\n");}else if(sc(s,"GET ",4)==0){printf("?");gets(c);b[ad(sk(s+4))
]=atoi(c);c[0]=0;}else if(sc(s,"IF ",3)==0){if(is(s+3))cmd(sk(s+6));}else if(s[
2]=='='){f=is(s+3);g=is(s+6);f=(s[5]=='+')?f+g:(s[5]=='-')?f-g:(s[5]=='*')?f*g:
(s[5]=='/')?f/g:(s[5]=='>')?f>g:(s[5]=='<')?f<g:(s[5]=='!')?f!=g:(s[5]=='=')?f
==g:(s[5]=='%')?f%g:f;b[ad(s)]=f;}else if(atoi(s)>0||s[0]=='0'){strcpy(l[atoi(s
)],s+3);if(m<atoi(s))m=atoi(s);}else if(s[0]=='L'){for(i=0;i<=m;i++)if(*l[i])
printf("%02d %s\n",i,l[i]);}else if(s[0]=='R'){for(*s=r=0;r<=m;r++)cmd(sk(l[r])
);}else if(s[0]=='Q'){exit(0);}else{puts("ERR");}}main(){for(;;){gets(c);if(*c)
{cmd(sk(c));puts("\nOK");}}}