| ||||||||||
| 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 | |||||||||
请各位老大帮忙看看!为什么老是wrong#include<iostream.h>
void main()
{
char left[3][7],right[3][7],result[3][7];
int a[12],i,j,time[12],num,k;
cin>>num;
for(k=0;k<num;k++)
{
for(j=0;j<12;j++)
{
a[j]=0;
time[j]=0;
};
for(i=0;i<3;i++)
cin>>left[i]>>right[i]>>result[i];
for(i=0;i<3;i++)
{
if(result[i][0]=='e')
{
for(j=0;left[i][j]!='\0';j++)
{
a[left[i][j]-'A']=1;
}
for(j=0;right[i][j]!='\0';j++)
{
a[right[i][j]-'A']=1;
}
};
};
for(i=0;i<3;i++)
{
for(j=0;left[i][j]!='\0';j++)
{
if(a[left[i][j]-'A']==0&&result[i][0]!='e')//2=light;3=heavy;
{
if(result[i][0]=='u')a[left[i][j]-'A']=3;
if(result[i][0]=='d')a[left[i][j]-'A']=2;
}
}
for(j=0;right[i][j]!='\0';j++)
{
if(a[right[i][j]-'A']==0&&result[i][0]!='e')
{
if(result[i][0]=='u')a[right[i][j]-'A']=2;
if(result[i][0]=='d')a[right[i][j]-'A']=3;
}
}
};
for(i=0;i<3;i++)
{
if(result[i][0]=='u')
{
for(j=0;left[i][j]!='\0';j++)
{
if(a[left[i][j]-'A']==2)a[left[i][j]-'A']=1;
}
for(j=0;right[i][j]!='\0';j++)
{
if(a[right[i][j]-'A']==3)a[right[i][j]-'A']=1;
}
}
if(result[i][0]=='d')
{
for(j=0;left[i][j]=='\0';j++)
{
if(a[left[i][j]-'A']==3)a[left[i][j]-'A']=1;
}
for(j=0;right[i][j]=='\0';j++)
{
if(a[right[i][j]-'A']==2)a[right[i][j]-'A']=1;
}
}
};
for(i=0;i<3;i++)
{
for(j=0;left[i][j]!='\0';j++)
{
if(a[left[i][j]-'A']>1)
time[left[i][j]-'A']++;
}
for(j=0;right[i][j]!='\0';j++)
{
if(a[right[i][j]-'A']>1)
time[right[i][j]-'A']++;
}
};
int temp=0;
for(i=0;i<12;i++)
{
if(time[temp]<=time[i])
temp=i;
else
a[i]=0;
};
if(a[temp]==2)cout<<(char)(temp+'A')<<" is the counterfeit coin and it is light.\n";
if(a[temp]==3)cout<<(char)(temp+'A')<<" is the counterfeit coin and it is heavy.\n";
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator