Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

样例过了但是一直WA,求大神解答,谢谢

Posted by Niannian_Wu at 2015-09-19 16:46:20 on Problem 1318
#include<stdio.h>
#include<string.h>
int a[101][27];//字典单词矩阵二
int b[101][27];//查询单词矩阵二
int c[101];//记录字典单词先后顺序的信息,越靠前的单词值越大
int e[101][51];//记录查询的单词每一个对应着几个字典里的词,分别是谁
int s[101];//中间字符串

/*排序*/
void function(int *p,int n)
{
	int i,limit,temps,k,q;
	limit=0;
	while(limit<n-1)
	{
		for(i=0;i<n-1-limit;i++)
		{
			k=*(p+i-1);
			q=*(p+i);
			if(*(p+i)<*(p+i+1))
			{
			
				temps=*(p+i);
				*(p+i)=*(p+i+1);
				*(p+i+1)=temps;
			}
		}
		limit++;
	}
}

int main()
{
	char d[101][7],w[101][7];
	int i,j,k,l,n,q,m;
	int *p;
//输入词典
	i=0;
	scanf("%s",&d[i]);
	while(strcmp(d[i],"XXXXXX"))
	{
		i++;
		scanf("%s",&d[i]);
	}
//输入要查询的单词	
	j=0;
	scanf("%s",&w[j]);
	while(strcmp(w[j],"XXXXXX"))
	{
		j++;
		scanf("%s",&w[j]);
	}
//存入A矩阵,并且记录单词的字母表排序信息
	for(k=0;k<i;k++)
	{
		for(l=0;l<strlen(d[k]);l++)
		{
			n=d[k][l]-97;
			a[k][n]++;
			c[k]=c[k]+n*(l+1);
		}
	}
//存入B矩阵
	for(k=0;k<j;k++)
	{
		for(l=0;l<strlen(w[k]);l++)
		{
			n=w[k][l]-97;
			b[k][n]++;
		}
	}
//比较A矩阵和B矩阵
	for(k=0;k<j;k++)
	{
		m=0;
		for(l=0;l<i;l++)
		{
			e[k][0]=0;
			for(q=0;q<26;q++)
			{
				if(a[l][q]==b[k][q])
					e[k][0]++;
			}
			if(e[k][0]==26)
			{
				e[k][m+1]=l+1;
				m++;
			}
		}
		e[k][50]=m;
	}
//输出
	for(k=0;k<j;k++)
	{
		if(e[k][50]==0)
            printf("NOT A VALID WORD\n");
		else if(e[k][50]==1)
		{
			q=e[k][1];
            printf("%s\n",d[q-1]);
		}
        else
		{
			for(l=1;l<=e[k][50];l++)
			{
				q=e[k][l];
				s[l-1]=c[q-1];
			}
			p=s;
	     	function(p,e[k][50]);
		    for(m=0;m<e[k][50];m++)
			{
				for(l=0;l<=101;l++)
				{
					if(c[l]==s[m])
						printf("%s\n",d[l]);
				}
			}
		} 
		printf("******\n");
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator