Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
20298 dulingxi 最长单词 C++ 通过 0 MS 252 KB 477 2023-06-15 20:41:11

Tests(3/3):


#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){ //cout<<max<<" "<<pos<<" "<<cnt<<endl; max = cnt; pos = i-cnt; } cnt = 0; } } for(int i = pos; i < pos+max; i++){ cout<<s[i]; } return 0; }


测评信息: