#include "stdio.h"
#include "string.h"
const int Len=102;
typedef struct
{
char name[Len];
char value[Len];
int flag;
}Keys;
Keys oldstr[Len],newstr[Len];
int deal(Keys *str)
{
int count=0;
char ch;
int i=0; //i 字母计数指针
while(ch!='}')
{
scanf("%c",&ch);
if(ch<='z' && ch>='a')
str[count].name[i++]=ch;
else if(ch==':')
i=0;
else if(ch<='9' && ch>='0')
str[count].value[i++]=ch;
else if(ch==',')
{
i=0;
count++;
}
}
return count+1;
}
void testprint(Keys *str,int n)
{
int i;
for(i=0;i<n;i++)
{
printf("%s.",str[i].name);
printf("%s ",str[i].value);
}
printf("\n");
}
int main()
{
int t;
scanf("%d",&t);
int i,j;
int counto,countn;
int sum;
while(t--)
{
//init
for(i=0;i<Len;i++)
{
for(j=0;j<Len;j++)
{
oldstr[i].name[j]='\0';
oldstr[i].value[j]='\0';
newstr[i].name[j]='\0';
newstr[i].value[j]='\0';
oldstr[i].flag=0; //flag初始化为0,value不变置1,改变置2
newstr[i].flag=0;
}
}
counto=deal(oldstr);
//testprint(oldstr,counto);
countn=deal(newstr);
//testprint(newstr,countn);
for(i=0;i<counto;i++)
{
for(j=0;j<countn;j++)
{
if(strcmp(oldstr[i].name,newstr[j].name)==0)
{
if(strcmp(oldstr[i].value,newstr[j].value)==0)
{
oldstr[i].flag=1;
newstr[j].flag=1;
}
else
{
oldstr[i].flag=2;
newstr[j].flag=2;
}
}
}
}
//搜索old串
for(i=0;i<counto;i++)
if(oldstr[i].flag!=1)
break;
for(j=0;j<countn;j++)
if(newstr[j].flag!=1)
break;
if(i==counto && j==countn)
printf("No changes\n");
else
//printf("have\n");
{
sum=0;
for(i=0;i<countn;i++)
{
if(newstr[i].flag==0)
{
sum++;
if(sum==1)
printf("+");
printf("%s ",newstr[i].name);
}
if(sum!=0 && i==countn-1)
printf("\n");
}
sum=0;
for(i=0;i<counto;i++)
{
if(oldstr[i].flag==0)
{
sum++;
if(sum==1)
printf("-");
printf("%s ",oldstr[i].name);
}
if(sum!=0 && i==countn-1)
printf("\n");
}
sum=0;
for(i=0;i<counto;i++)
{
if(oldstr[i].flag==2)
{
sum++;
if(sum==1)
printf("*");
printf("%s ",oldstr[i].name);
}
if(sum!=0 && i==countn-1)
printf("\n");
}
}
printf("\n");
}
return 0;
}
现场赛的C题终于写出来了。。。终于感觉好点了,虽然打码不一定精简,不过也算解了心结了,就因为这题没得奖啊。。。花了1个多小时。。。