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 guojinyu at 2011-10-23 20:32:14 on Problem 1035
#include <iostream>
#include <string>
using namespace std;
string dic[10010],che[60];
int n=1,m=1;
void init()
{
  cin>>dic[n];
  while(dic[n][0]!='#')
  {
	n++;
	cin>>dic[n];
  }
  n--;
  cin>>che[m];
  while(che[m][0]!='#')
  {
	m++;
	cin>>che[m];
  }
  m--;
}
void work(int x)
{
  int i,j,k,c1=0,f2=0,f3=0;
  for(i=1;i<=n;i++)
	if(dic[i]==che[x])
	{
	  cout<<che[x]<<" is correct"<<endl;
	  return;
	}
  cout<<che[x]<<":";
  for(i=1;i<=n;i++)
  {
	if(che[x].length()==dic[i].length())
	{
	  for(j=0;j<che[x].length();j++)
		if(dic[i][j]!=che[x][j])
	      c1++;
	  if(c1==1)
	    cout<<' '<<dic[i];
	}
	if(che[x].length()==dic[i].length()+1)
    {
	  for(j=0;j<dic[i].length();j++)
		if(dic[i][j]!=che[x][j])
		  break;
	  if(j==dic[i].length())
	    cout<<' '<<dic[i];
	  if(j!=dic[i].length())
	  {
		for(k=j+1;k<che[x].length();k++)
		  if(dic[i][k-1]!=che[x][k])
		  {
			f2=1;
			break;
		  }
		if(f2==0)
		  cout<<' '<<dic[i];
		if(f2!=0)
		  f2=0;
	  }
    }
	if(che[x].length()==dic[i].length()-1)
    {
	  for(j=0;j<che[x].length();j++)
		if(dic[i][j]!=che[x][j])
		  break;
	  if(j==che[x].length())
	    cout<<' '<<dic[i];
	  if(j!=che[x].length())
	  {
		for(k=j+1;k<dic[i].length();k++)
		  if(dic[i][k]!=che[x][k-1])
		  {
			f3=1;
			break;
		  }
		if(f3==0)
		  cout<<' '<<dic[i];
		if(f3!=0)
		  f3=0;
	  }
    }
  }
  cout<<endl;
}
void solve()
{
  int i;
  for(i=1;i<=m;i++)
	work(i);
}
int main()
{
  init();
  solve();
  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