Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
152718 冯诚阳 统计特定单词数 C++ Wrong Answer 3 MS 280 KB 988 2026-05-01 18:57:05

Tests(2/11):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ string a,b,c=""; getline(cin,a); getline(cin,b); int cnt=0,pos1=-1,i; for(i=0;a[i]!='\0';i++) if(a[i]>='A'&&a[i]<='Z') a[i]+=32; for(i=0;b[i]!='\0';i++) if(b[i]>='A'&&b[i]<='Z') b[i]+=32; for(i=0;b[i]!='\0';i++){ if(b[i]!=' ') c=c+b[i]; else{ c=""; if(c==a){ if(pos1==-1){ pos1=i-a.size(); } cnt++; } } } if(c==a){ if(pos1==-1){ pos1=i-a.size(); } cnt++; } if(pos1==-1) cout<<-1; else cout<<cnt<<" "<<pos1; return 0; }


Run Info:

------Input------
alun OK Alun is the best teacher of TCJY
------Answer-----
1 3
------Your output-----
-1