Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 找到了

Posted by shenfangyi at 2006-07-25 21:45:15 on Problem 2849
In Reply To:求救！到底哪错了？ Posted by:shenfangyi at 2006-07-25 20:39:01
```> #include<stdio.h>
> #include<string.h>
> unsigned char m[32768];
> char p[128001],s[1000000],o[10000000];
> main()
> {
>     int n;
>     scanf("%d",&n);
>     for(int z=1;z<=n;z++)
>     {
>         int l=0;
>         gets(s);
>         int c=0;
>         while(strcmp("end",s)&&(c>=0)&&(c<2))
>         {
>             char *t=s;
>             while(*t)
>             {
>                 if((*t=='<')||(*t=='>')||(*t=='+')||(*t=='-')||(*t=='.')||(*t=='[')||(*t==']'))
>                 {
>                     if(*t=='[')c++;
>                     else if(*t==']')c--;
>                     p[l++]=*t;
>                 }
>                 else if(*t=='%')break;
>                 t++;
>             }
>             gets(s);
>         }
>         printf("PROGRAM #%d:\n",z);
>         if(c)puts("COMPILE ERROR");
>         else
>         {
>             for(int i=0;i<32768;i++)m[i]=0;
>             char *t=p,*q=o;
>             *q=0;
>             int a=0,c=1;
>             while(((t-p)<l))
>             {
>                 switch(*t)
>                 {
>                     case '>':a=(a+1)%32768;break;
>                     case '<':a=(a+32767)%32768;break;
>                     case '+':m[a]++;break;
>                     case '-':m[a]--;break;
>                     case '.':*q=m[a];*(++q)=0;break;
>                     case '[':
>                         if(!m[a])
>                         {
>                             while(((t-p)<l)&&(*t!=']'))t++;
>                         }
>                         break;
>                     case ']':
>                         if(m[a])
>                         {
>                             while((t>=p)&&(*t!='['))t--;
>                         }
>                             break;
>                 }
>                 t++;
>             }
>             puts(o);
>         }
>     }
> }
```

Followed by: