📄 1844121_wa.c
字号:
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
void main()
{
int i, n, m, mark[20];
char str1[10], str2[10], tmp[10], t[10];
scanf("%d",&n);
while(n--)
{
for(i = 0; i < 20; i++) mark[i] = 0;
m = 3;
while(m--)
{
scanf("%s%s%s",str1,str2,tmp);
if(strcmp(tmp,"down")==0)
{
strcpy(tmp,"up");
strcpy(t,str1);
strcpy(str1,str2);
strcpy(str2,t);
}
if(strcmp(tmp,"even")==0)
{
for(i = 0; str1[i] != '\0'; i++)
mark[str1[i]-'A'] = 1;
for(i = 0; str2[i] != '\0'; i++)
mark[str2[i]-'A'] = 1;
}
if(strcmp(tmp,"up")==0)
{
for(i = 0; i < 12; i++)
if(strchr(str1,(char)(i+65))==NULL&&strchr(str2,(char)(i+65))==NULL)
mark[i] = 1;
for(i = 0; str1[i] != '\0'; i++)
if(!mark[str1[i]-'A']) mark[str1[i]-'A'] = 2;
else if(mark[str1[i]-'A']==-1) mark[str1[i]-'A'] = 1;
for(i = 0; str2[i] != '\0'; i++)
if(!mark[str2[i]-'A']) mark[str2[i]-'A'] = -1;
else if(mark[str2[i]-'A']==2) mark[str2[i]-'A'] = 1;
}
}
for(i = 0; i < 12; i++) printf("%d ",mark[i]);printf("\n\n");
for(i = 0; i < 12; i++)
{
if(mark[i]==-1)
{printf("%c is the counterfeit coin and it is light.\n",i+65);break;}
if(mark[i]==2)
{printf("%c is the counterfeit coin and it is heavy.\n",i+65);break;}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -