| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
找到了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: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator