WA 求解释
#include<stdio.h>
#include<string.h>

struct hype
{
	char tag[10];
	char url[31];
};

struct store
{
	char url[31];
	int vote;
};

struct hype hyperlinks[10000];
struct store g[100000]={0};

void bubble(struct hype *a,int n)
{
	int done=0,k=1,i;
	struct hype temp;
	
	while(!done)
	{
		done=1;
		for(i=0;i<n-k;i++)
		{
			if(strcmp(a[i].url,a[i+1].url)>0)
			{
				temp=a[i];
				a[i]=a[i+1];
				a[i+1]=temp;
				done=0;
			}
		}
		k++;
	}
	
}

void bubble1(struct store *a,int n)
{
	int done=0,k=1,i;
	struct store temp;
	
	while(!done)
	{
		done=1;
		for(i=0;i<n-k;i++)
		{
			if(a[i].vote<a[i+1].vote)
			{
				temp=a[i];
				a[i]=a[i+1];
				a[i+1]=temp;
				done=0;
			}
		}
		k++;
	}
	
}
int Find(char *c,char *d)//字符匹配的问题,先用朴素的匹配方法
{
    int l1,l2,i,j,flag;
    l1=strlen(c);
    l2=strlen(d);
    for (i=0;i<=l1-l2;i++)
	{
        flag=1;
        for (j=0;j<l2;j++)
            if (c[i+j]!=d[j]) 
			{
				flag=0;
				break;
			}
			if (flag) 
				return i;
	}
    return -1;	
}

void Search(char *target,int n)
{
	int i,k=0,flag=0;
	
	
	for(i=0;i<n;i++)
	{
		if(Find(hyperlinks[i].tag,target)!=-1)
		{
			if(!flag)
			{
				strcpy(g[k].url,hyperlinks[i].url);
				g[k].vote++;
				flag=1;
				continue;
			}
			if(strcmp(g[k].url,hyperlinks[i].url)==0)
			{
				g[k].vote++;
				continue;
			}
			else
			{
				k++;
				strcpy(g[k].url,hyperlinks[i].url);
				g[k].vote++;
			}
			
		}
		
	}
	if(flag)
	{
		bubble1(g,k+1);
		for(i=0;i<=k;i++)
		{
			printf(\"%s %d\\n\",g[i].url,g[i].vote);
			g[i].vote=0;
		}
	}
	else
		printf(\"Sorry, no result satisfied.\\n\");
	
}

int main()
{
	int n,q,i;
	char target[8];
	
	scanf(\"%d\",&n);
	
	for(i=0; i<n; i++)
	{
		scanf(\"%s%s\",hyperlinks[i].tag,hyperlinks[i].url);
	}
	
	
	bubble(hyperlinks,n);//将URL按字典序排序
	
						 /*for(i=0;i<n;i++)
						 {
						 printf(\"%s %s\\n\",hyperlinks[i].tag,hyperlinks[i].url);
}*/
	
	
	
    scanf(\"%d\",&q);
	
	while(q--)
	{
		scanf(\"%s\",target);
		Search(target,n);//搜索PAGE
		if(q!=0)
			putchar(\'\\n\');
	}			
	return 0;
}

© 2015 HUST ACMICPC TEAM. All Right Reserved.