最长单词(计数定位)
#include<bits/stdc++.h>
using namespace std;
int main(){
string a;
getline(cin, a);
int l = a.length();
int max = 0, currentmax = 0;
int index = 0;
for(int i = 0; i < l; i++){
if((a[i] >= 'a' && a[i] <= 'z' )|| (a[i] >= 'A' && a[i] <= 'Z' )){
currentmax ++;}
else{currentmax = 0;}
if(currentmax > max){
max = currentmax;
index = i;
}
}
string result = a.substr(index - max + 1, max);
cout << result;
return 0;
}