Run ID:158416
提交时间:2026-08-21 15:39:55
#include<bits/stdc++.h> using namespace std; char a[30]; char b[10005]; //转小写函数 char toLow(char c) { if(c>='A'&&c<='Z') return c+32; return c; } int main() { cin.getline(a,30); cin.getline(b,10005); int lena=strlen(a); int lenb=strlen(b); int cnt=0; int first_pos=-1; for(int i=0;i<lenb;i++) { //剩余字符不够,直接结束循环 if(i+lena>lenb) break; bool match=true; for(int j=0;j<lena;j++) { char ca=toLow(a[j]); char cb=toLow(b[i+j]); if(ca!=cb) { match=false; break; } } if(match) { cnt++; if(first_pos==-1) first_pos=i; } } if(cnt>0) { cout<<cnt<<" "<<first_pos<<endl; } else { cout<<-1<<endl; } return 0; }