蒟蒻20分求助,有几个RE和WA
查看原帖
蒟蒻20分求助,有几个RE和WA
553640
Konjac0629楼主2021/8/19 09:34

先上代码:

#include <iostream>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){
  string a,b,temp;
  int t=0,p=0,ap=0;
  bool flag=false;
  getline(cin,a);
  getline(cin,b);
  transform(a.begin(),a.end(),a.begin(),::tolower);
  transform(b.begin(),b.end(),b.begin(),::tolower);
  for(int i=0;i<b.length();i++){
    while(b[i]!=' '){
      temp.push_back(b[i]);
      i++;
    }
    if(a==temp){
      if(flag==false){
        ap=p;
        flag=true;
      }
      t++;
    }
    temp="";
    p++;
  }
  if(t!=0)
    cout << t << " " << ap << endl;
  else
    cout << -1 << endl;
  return 0;
}

评测情况:

2021/8/19 09:34
加载中...