提交时间:2023-07-31 22:12:47

运行 ID: 23796

#include<iostream> #include<cstring> using namespace std; int main() { char s[505]; gets(s); int max = 0; int pos = 0; int cnt = 0; for(int i = 0; i < strlen(s); i++){ if(s[i] != ' ' && s[i] != '.'){ cnt++; } else{ if(cnt>max){ max = cnt; pos = i-cnt; } cnt = 0; } } for(int i = pos; i < pos+max; i++){ cout<<s[i]; } return 0; }