Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
117266 汤奕硕 出现k次的字符 C++ Compile Error 0 MS 0 KB 548 2025-04-15 20:42:55

Tests(0/0):


Code:

#include <bits/stdc++.h> using namespace std; int main() { int k; cin>>k; int ct=0; string a; cin>>a; char c=a[0]; for(int i=0; i<a.size(); ++i) { if(a[i]==c) ct++; else { if(ct>=k) cout<<c; return 0; else { c=s[i]; ct=1; } } } if(ct>=k){ cout<<c; return 0; } cout<<"No"; return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:12:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i