| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
高手帮我#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator