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

高手帮我

Posted by kric at 2007-03-31 15:35:54 on Problem 2681
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	char p[46],g[46];
	int n,i,j,lp,lg,k,count;
	cin>>n;
	getchar();
	for(i=0;i<n;i++)
	{
		count=0;
		gets(p);
		gets(g);
        lp=strlen(p);
		lg=strlen(g);
		if(!lp)
			printf("%Case #%d:  %d\n",i+1,lg);
		if(!g)
			printf("%Case #%d:  %d\n",i+1,lp);
			for(j=0;j<lp;j++)
			{
				if(p[j]=='*')
					continue;
				for(k=0;k<lg;k++)
				{
					if(g[k]=='*')
						continue;
					if(p[j]==g[k])
					{
                       p[j]=g[k]='*';
					   break;
					}
				}
			}
			
			for(j=0;j<lp;j++)
			{
                 if(p[j]!='*')
					 count++;
			}
			for(k=0;k<lg;k++)
			{
				if(g[k]!='*')
					count++;
			}
			printf("Case #%d:  %d\n",i+1,count);
	}
	return 1;
}

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