| ||||||||||
| 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 | |||||||||
1013 compile error!? 我在自己的机子测N组数据都能过……#include <stdio.h>
#include <string.h>
void dele(int n,char c[])
{
int i,clen;
clen=strlen(c);
for(i=n;i<clen;i++)
{
c[i]=c[i+1];
}
}
void del(char a[],char b[])
{
int i,j,alen,blen;
alen=strlen(a);
blen=strlen(b);
for (i=0;i<alen;i++)
{
for(j=0;j<blen;j++)
{
if(a[i]==b[j]) dele(j,b);
}
}
}
int main()
{
int i,j,k,m,n,times,llen,rlen,alen;
i=j=1;
char left[10],right[10],status[10],allbackup[20];
char all[20]={"ABCDEFGHIJKL"};
int flag[20]={0};
scanf("%d",×);
for(i=1;i<=times;i++)
{
for(j=1;j<=3;j++)
{
scanf("%s %s %s",left,right,status);
llen=strlen(left);
rlen=strlen(right);
if (status[0]=='e')
{
for(m=0;m<llen;m++)
{
for(n=0;n<12;n++)
{
if((left[m]==all[n])||(right[m]==all[n])) flag[n]=2;
}
}
}
/* 可以用以下代码测试even状态时的代码对错
for(k=0;k<12;k++)
{
if(flag[k]==2) printf("确定为真银币:%c\n",all[k]);
}
*/
if(status[0]=='u')
{
strcpy(allbackup,all);
del(left,all);del(right,all);
alen=strlen(all);
for(n=0;n<12;n++)
{
for(m=0;m<alen;m++)
{
if(allbackup[n]==all[m]) flag[n]=2;
}
}
strcpy(all,allbackup);
/* codes below will test the exactness from "strcpy" here
for(k=0;k<12;k++)
{
if(flag[k]==2) printf("确定为真银币:%c\n",all[k]);
}
*/
for(n=0;n<12;n++)
{
for(m=0;m<llen;m++)
{
if(left[m]==all[n])
{
if(flag[n]==0) flag[n]=1;
if(flag[n]==-1) flag[n]=2;
}
if(right[m]==all[n])
{
if(flag[n]==0) flag[n]=-1;
if(flag[n]==1) flag[n]=2;
}
}
}
/* codes below are to test the exactness of the codes above
for(k=0;k<12;k++)
{
if (flag[k]==-1) printf("%c may be light\n",all[k]);
if (flag[k]==1) printf("%c may be heavy\n",all[k]);
if (flag[k]==2) printf("%c is real\n",all[k]);
}
*/
}
if(status[0]=='d')
{
strcpy(allbackup,all);
del(left,all);del(right,all);
alen=strlen(all);
for(n=0;n<12;n++)
{
for(m=0;m<alen;m++)
{
if(allbackup[n]==all[m]) flag[n]=2;
}
}
strcpy(all,allbackup);
/* codes below will test the exactness from "strcpy" here
for(k=0;k<12;k++)
{
if(flag[k]==2) printf("确定为真银币:%c\n",all[k]);
}
*/
for(n=0;n<12;n++)
{
for(m=0;m<llen;m++)
{
if(left[m]==all[n])
{
if(flag[n]==0) flag[n]=-1;
if(flag[n]==1) flag[n]=2;
}
if(right[m]==all[n])
{
if(flag[n]==0) flag[n]=1;
if(flag[n]==-1) flag[n]=2;
}
}
}
/* codes below are to test the exactness above
for(k=0;k<12;k++)
{
if (flag[k]==-1) printf("%c may be light\n",all[k]);
if (flag[k]==1) printf("%c may be heavy\n",all[k]);
if (flag[k]==2) printf("%c is real\n",all[k]);
}
*/
}
}
for(k=0;k<12;k++)
{
if(flag[k]==1) printf("%c is the counterfeit coin and it is heavy.\n",allbackup[k]);
if(flag[k]==-1) printf("%c is the counterfeit coin and it is light.\n",allbackup[k]);
}
for(k=0;k<20;k++)
{
flag[k]=0;
}
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator