以下代码在oj平台上显示答案错误27%,
求各位指点。
#include<stdio.h>
#include<string.h>
char ch[10000001];
char ch1[11];
int main()
{
while(gets(ch1)!=NULL){
int sum=0,sum1=0,flag=0;
gets(ch);
for(int i=0;ch[i]!='\0';i++)
if(ch[i]>=97&&ch[i]<=122)
ch[i]-=32;
for(int i=0;ch1[i]!='\0';i++)
if(ch1[i]>=97&&ch1[i]<=122)
ch1[i]-=32;
char* p;
p=strtok(ch," ");
while(p)
{
if(strcmp(p,ch1)==0)
{
sum++;
flag=1;}
if(flag==0)sum1+=strlen(p)+1;
p=strtok(NULL," ");
}
if(sum!=0)printf("%d %d\n",sum,sum1);
else printf("-1\n");}
return 0;
}