多写了一点无意义的判断,可以删掉。
这题很友好。
#include<stdio.h>
#include<string.h>
int main()
{
char a[1000];
scanf("%s",a);
char num[3] = {'0','0','0'};
int j=0;
for(int i=0; a[i]!='\0'; i++)
{
if(a[i]=='=' && a[i-1] == ':')
{
if(a[i-2] == 'a')
{
if(a[i+1]>='0' && a[i+1]<='9')num[0] = a[i+1];
else if(a[i+1] == 'b')num[0] = num[1];
else if(a[i+1] == 'c')num[0] = num[2];
}
if(a[i-2] == 'b')
{
if(a[i+1]>='0' && a[i+1]<='9')num[1] = a[i+1];
else if(a[i+1] == 'a')num[1] = num[0];
else if(a[i+1] == 'c')num[1] = num[2];
}
if(a[i-2] == 'c')
{
if(a[i+1]>='0' && a[i+1]<='9')num[2] = a[i+1];
else if(a[i+1] == 'a')num[2] = num[0];
else if(a[i+1] == 'b')num[2] = num[1];
}
}
}
for(int i=0; i<3; i++)
{
printf("%c",num[i]);
if(i!=2)printf(" ");
}
return 0;
}