Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
132889 石水生 出现k次的字符 C++ Accepted 1 MS 276 KB 627 2025-10-12 15:46:59

Tests(10/10):


Code:

#include <bits/stdc++.h> using namespace std; //strlen()获取字符串长度 // strcat(a,b)将b拼接到a后面,b本身不变 //strlen //strcpy //strcmp int main(){ int k; char a[2500]; cin>>k>>a; int sum=0; char word; for(int i=0;i<strlen(a);i++){ if(word!=a[i]){ word=a[i]; sum=1; }else{ sum++; } if(sum==k){ cout<<word; return 0; } //cout<<a[i]<<" "<<sum; } cout<<"No"; } //a[]="abcdqwer" strlen(a) //a[4] // 01234 // a[4]=b[0]; // a[5]=b[1]; // a[6]=b[2]; // a[7]=b[3]; //b[]="qwer",strlen(b)