| ||||||||||
| 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 | |||||||||
为什么是wrong answer哪位高手能给点其他的测试数据呢?或者说几点注意点。我也搞不懂哪里错了。(测试数据和自己想的数据已经通过了)
#include <stdio.h>
#include <string.h>
#include <math.h>
struct node
{
char str[30];
int count;
}s1[100],s2[100];
void change(char a[])
{
int i,j;
for (i=0,j=0;a[i];i++)
{
if (a[i]>='A'&&a[i]<='Z')
a[j++]=a[i]-'A'+'a';
else if((a[i]>='a'&&a[i]<='z')||(a[i]>='0'&&a[i]<='9')||a[i]==' ')
a[j++]=a[i];
}
a[j]='\0';
}
void main()
{
char s[300],a[300],b[20],t[50];
int i,j,k,sum,n,max,max1;
float result;
gets(s);
gets(b);
change(s);
for(i=0;i<100;i++)
s1[i].count=0;
i=0;
max=0;
while (s[i])
{
if(s[i]==' ')i++;
j=0;
while(s[i]&&s[i]!=' ')
t[j++]=s[i++];
t[j]='\0';
for(k=0;k<max;k++)
if (strcmp(t,s1[k].str)==0)
{
s1[k].count++;
break;
}
if(k==max)
{
strcpy(s1[max].str,t);
s1[max].count++;
max++;
}
}
gets(a);
while(strcmp(a,"----------")!=0)
{
change(a);
result=0;
for(i=0;s2[i].count;i++)
s2[i].count=0;
i=0;
max1=0;
while (a[i])
{
if(a[i]==' ')i++;
j=0;
while(a[i]&&a[i]!=' ')
t[j++]=a[i++];
t[j]='\0';
for(k=0;k<max1;k++)
if (strcmp(t,s2[k].str)==0)
{
s2[k].count++;
break;
}
if(k==max1)
{
strcpy(s2[max1].str,t);
s2[max1].count++;
max1++;
}
}
i=0;
while(i<max)
{
n=0;
for(j=0;j<max1;j++)
if(strcmp(s1[i].str,s2[j].str)==0)
n=n+s2[j].count;
if(n)
{
sum=s1[i].count*n;
result+=sqrt(sum);
}
i++;
}
printf("%.2f\n",result);
gets(b);
gets(a);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator