2026-06-22 19:50:02
发布于:广东
有没有哥能告诉我,我的代码错哪了(应该是有问题的)
#include<iostream>
#include<string>
#include<cctype>
#include<algorithm>
using namespace std;
int main(){
string s,t;
int u=-1e9,cut=0,i=0;
cin>>s;
transform(s.begin(),s.end(),s.begin(),::toupper);
while(cin>>t){
transform(t.begin(),t.end(),t.begin(),::toupper);
if(s==t){
if(u==-1e9)u=i;
cut++;
}
i+=t.size()+1;
}
if(u!=-1e9){
cout<<cut<<" "<<u;
}else{
cout<<-1;
}
return 0;
}
全部评论 4
3
5天前 来自 浙江
0没加
#include<string>6天前 来自 浙江
0没试过其他不知道
6天前 来自 浙江
0
6
6天前 来自 上海
0比如 这种情况,你的位置就会算错
td
+++Td tLWCsrmt
假设前面的三个加号都是空格1周前 来自 广东
0





































有帮助,赞一个