Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
11845 | 徐一喆 | 最长的单词 | C++ | Accepted | 2 MS | 696 KB | 529 | 2021-05-17 19:41:10 |
#include <bits/stdc++.h> using namespace std; void longword(char s[]); int main() { char str[50]; gets(str); longword(str); return 0; } void longword(char s[]) { int max=0, len=0; char m[20], ma[20]; int n=strlen(s); for (int i=0, j=0; i<=n; i++) { if ((s[i]>='a'&&s[i]<='z')||(s[i]>='A'&&s[i]<='Z')) m[len++]=s[i]; else { m[len]='\0'; len>max ? max=len, strcpy(ma, m), len=0 : len=0; } } puts(ma); }