这边建议直接string
```
s[i]+='a'-'A';
```
这一步是什么意思撒 转大小写吗
推荐```
toupper(s)
```
by 呆呆的她啊 @ 2023-12-09 13:03:15
@[呆呆的她啊](/user/226167) 这题会卡char吗qwq?
by best_lover @ 2023-12-09 13:07:30
@[卖导弹的](/user/359485) 不会卡char的 只要你正确输入 但是用string才是正解
by 呆呆的她啊 @ 2023-12-09 13:15:18
```c
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
string sent,word;
int lens,lenw,t,pos;
int main()
{
getline(cin,word); // to
getline(cin,sent); // to be or 字符串含有空格输入,不可以用cin,否则to me只能读到to
lenw=word.size(); // to 2
lens=sent.size();// to me be of xx x
for(int i=0;i<lenw;i++)
word[i]=toupper(word[i]); //转成大写
for(int i=0;i<lens;i++)
sent[i]=toupper(sent[i]);
t=0;
for(int i=0;i<=lens-lenw;i++)// shengyu de changdu
{
int j;
for(j=0;j<lenw;++j)
{
if(sent[j+i]!=word[j]) break;
if(i>0&&sent[i-1]!=' ') break; //不是单词开头就结束
}
if(j==lenw&&(sent[j+i]==' '||j+i==lens)) //单词长度匹配,后面是空格或者句末
{
t++;
if(t==1) pos=i;
}
}
if(t==0)cout<<-1;
else cout<<t<<" "<<pos;
return 0;
}
```
by 呆呆的她啊 @ 2023-12-09 13:15:52
@[呆呆的她啊](/user/226167) A了!!谢谢!
by best_lover @ 2023-12-09 13:31:47