Run ID:115024
提交时间:2025-03-26 20:52:19
#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; }