include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{ string str; cin >> str; int len = str.size(); vector<int> dp(len, 1); vector<char> ans; int maxlen = 1; int k = 0; for (int i = 1; i < len; i++) { if (str[i] == str[i - 1]) dp[i] = dp[i - 1] + 1; if (dp[i] > maxlen) maxlen = dp[i]; } for (int i = 0; i < len; i++) { if (dp[i] == maxlen) { ans.push_back(str[i]); } } if (ans.size() > 1) { cout << ans[k]; for (k = 1; k < ans.size(); k++) { cout << ';' << ans[k]; } cout << endl; } else { cout << ans[k] << endl; } return 0;
}
本地编译实例都没问题,但在线就是0,求赐教,问题出现在哪?
#汇顶科技##笔试题目#