| ||||||||||
| 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 | |||||||||
Re:我是新手,请帮忙看看代码,是不是因为循环太多超时的?谢谢!In Reply To:我是新手,请帮忙看看代码,是不是因为循环太多超时的?谢谢! Posted by:ccnuteam4 at 2008-08-21 18:05:27 我也是刚开始学的,看看我的AC来的
#include <iostream>
#include <string.h>
using namespace std;
int main()
{ int n;
char a[50];
char b[50];
int al,bl;
int i,j;
int k=0;
int count;
cin>>n;
char c[10];
gets(c);
while(n-->0)
{k++;
gets(a);
gets(b);
al=strlen(a);
bl=strlen(b);
for(i=0,count=0;i<bl;i++)
for(j=0;j<al;j++)
if(b[i]==a[j]) {a[j]='0';count++;break;}
cout<<"Case #"<<k<<": "<<al+bl-2*count<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator