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 cjqiu at 2008-12-05 13:32:12 on Problem 1035
//WA


#include <stdio.h>
#include <string.h>


int main()
{
	char D[10005][50],C[100][50],A[50],m;
	int i,j,k,n,lend,rlend,rlenc,f[100],d[10005],index,temp;
	freopen("acm.txt","r",stdin);
	for(i=0;i<10005;i++)
	{
		scanf("%s",D[i]);
		if( D[i][0]=='#' )
			break;
	}
	lend=i;
	for(i=0;i<100;i++)
	{
		scanf("%s",C[i]);
		rlenc=strlen(C[i]);
		if( C[i][0]!='#' )
		{
			index=0;
			for(j=0;j<lend;j++)
			{
				f[i]=0;
				rlend=strlen(D[j]);
				if( rlend==rlenc )
				{
					strcpy(A,C[i]);
					if( !strcmp(A,D[j]) )
					{
						f[i]=1;
						break;
					}
				}
				if( f[i]==0 )
				{
					if( rlend==rlenc )// 1
					{
						
						for(k=0;k<rlenc;k++)
						{
							strcpy(A,C[i]);
							for(m='a';m<='z';m++)
							{
								if( D[j][k]==m )
								{
									A[k]=m;
								//	
									if( !strcmp(A,D[j]) )
									{
										d[index]=j;
										index++;
									}
								}
							}
						}
					}// 1
					if( rlend==rlenc+1 )// 2
					{
						
						for(k=0;k<=rlenc;k++)
						{	
							strcpy(A,C[i]);
							for(m='a';m<='z';m++)
							{	
								if( D[j][k]==m )
								{
									for(n=rlenc+1;n>k;n--)
										A[n]=A[n-1];
									A[k]=m;
								//	
									if( !strcmp(A,D[j]) )
									{
										d[index]=j;
										index++;
									}
								}
							}
						}
					}// 2
					if( rlend==rlenc-1 )// 3
					{
						
						for(k=0;k<rlenc;k++)
						{
							strcpy(A,C[i]);
							for(n=k;n<rlenc+1;n++)
								A[n]=A[n+1];
							if( A[k]==D[j][k] )
							{
									
								if( !strcmp(A,D[j]) )
								{
									d[index]=j;
									index++;
								//	printf(" %s",D[j]);
								}
							}
						}
					}// 3
				}
			}
			if( f[i]==1 )
			{
				printf("%s is correct\n",C[i]);
				continue;
			}
			
			if(index!=0)
			{
				for(k=0;k<index;k++)
				{
					for(n=index-1;n>k;n--)
					{
						if( d[n-1]>d[n] )
						{
							temp=d[n];
							d[n]=d[n-1];
							d[n-1]=temp;
						}
					}
				}
				printf("%s:",C[i]);
				for(k=0;k<index;k++)
					printf(" %s",D[d[k]]);
			}
			else
				printf("%s:",C[i]);
			printf("\n");
		}
		else
			break;
	}
	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