| ||||||||||
| 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:wx1166750 at 2006-09-04 11:56:06 > ----------------------------------
> 数组开少了
> 这是我改完后的程序
> #include<iostream>
> #include<cstdio>
> #include<cmath>
> using namespace std;
> int main()
> {
> char a[200],b[200];
> int n,i,j,sum,num2[26],num1[26];
> scanf("%d",&n);scanf("\n");
> for(j=1;j<=n;j++)
> {
> gets(a);
> gets(b);
> memset(num1,0,sizeof(num1));
> memset(num2,0,sizeof(num2));
> sum=0;
> for(i=0;i<strlen(a);i++)
> num1[a[i]-'a']++;
> for(i=0;i<strlen(b);i++)
> num2[b[i]-'a']++;
> for(i=0;i<26;i++)
> sum+=(int)abs(num1[i]-num2[i]);
> printf("Case #%d: %d\n",j,sum);
> }
> return 0;
> }
我也是按这个思路来做,但数组那里开到50就已足够了,在C++可以编译通过,
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator