Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
115024 小徐老师 最长的单词 C++ Accepted 0 MS 264 KB 1098 2025-03-26 20:52:19

Tests(1/1):


Code:

#include <bits/stdc++.h> using namespace std; char s[100 + 5]; char ans_s[100 + 5]; char temp_s[100 + 5]; int main() { //char s[100 + 5]; //char ans_s[100 + 5]; //char temp_s[100 + 5]; //char s[105]; gets(s); int Max_len = 0; int temp_len = 0; //char temp_s[100 + 5]; for(int i = 0; i < strlen(s); ++i) { if(s[i] != ' '){ temp_s[temp_len++] = s[i]; //cout << "temp_s11= " << temp_s << endl; } else { //Max_len = max(Max_len, temp_len); if(temp_len > Max_len) { Max_len = temp_len; strcpy(ans_s, temp_s); //memset(temp_s, 0, sizeof temp_s); //temp_len = 0; } temp_len = 0; memset(temp_s, 0, sizeof temp_s); } //cout << "temp_s= " << temp_s << endl; } //cout << ans_s << endl; if(temp_len > Max_len) { strcpy(ans_s, temp_s); } cout << ans_s << endl; return 0; }