Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
40758 | yejiaxiangBMT | 连续出现的字符 | C++ | Accepted | 0 MS | 248 KB | 397 | 2024-02-16 00:58:13 |
#include<iostream> #include<cstring> using namespace std; char a[1001]; int main() { int k; cin>>k>>a; int count=1; bool exist=0; if(k==1){ cout<<a[0]; } else{ for(int i=1;i<int(strlen(a));i++){ if(a[i]==a[i-1]){ count++; if(count==k){ cout<<a[i]; exist = 1; break; } } } } if(exist == 0){ cout<<"No"; } return 0; }