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

小小代码 ac

Posted by trk1009 at 2012-07-23 18:57:16 on Problem 1035
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
	int n=0,m=0,i,j,h,g,a,w,r;
	char s[10001][16],b[50][16];
	while(scanf("%s",s[n])!=EOF)
	{
		if(strcmp(s[n],"#")==0)
			break;
        n++;
	}
	while(scanf("%s",b[m])!=EOF)
	{
		if(strcmp(b[m],"#")==0)
			break;
		m++;
	}
	for(i=0;i<m;i++)
	{
		int flag=1,z=0;
		for( w=0,r=0;w<n;w++)
		{
			if(strcmp(b[i],s[w])==0)
			{
				cout<<b[i]<<" "<<"is correct"<<endl;
			    r=1;
				break;
				
			}
		}
		if(r==1) continue;
		
		for(j=0;j<n;j++)
		{
			 if(strlen(b[i])==strlen(s[j]))
			{
				int x=0;
				for(int g=0;g<strlen(s[j]);g++)
				{
					if(s[j][g]!=b[i][g])
						x++;
				}
				if(x==1)
				{
					z=1;
					if(flag==1)
						cout<<b[i]<<":";
	
						cout<<" ";
					    cout<<s[j];
					flag++;
				}
			 }
			else if(strlen(b[i])==strlen(s[j])+1)
			{
				for( g=0,h=0,a=0;g<strlen(b[i]);)
				{
					if(b[i][g]==s[j][a]) 
						a++,g++;
					else h++,g++;
				}
				if(h==1)
				{
					z=1;
					if(flag==1)
						cout<<b[i]<<":";
	                
						cout<<" ";
					cout<<s[j];
					flag++;
					
				}
			}
			else if(strlen(b[i])==strlen(s[j])-1)
			{
				for( g=0,h=0,a=0;g<strlen(s[j]);)
				{
					if(b[i][a]==s[j][g])
						a++,g++;
					else  h++,g++;
				}
				if(h==1)
				{
					z=1;
					if(flag==1)
						cout<<b[i]<<":";
	                  
						cout<<" ";
					cout<<s[j];
					flag++;
				}
			}
			
		}
		
	    if(z==0)
		{     	
			cout<<b[i]<<":"; 
		} 
	    cout<<endl;

	}

		
		
	
	
	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