输入一个字符串(字符串按字母顺序排列)和一个数字n,例AAAABCCDDEEEFF,3。找出字符串中长度为n的子串的下标并返回,例:0,1,10
求助大佬们,求调程序。程序如下:
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
int n,a[10],count=0;
cin>>s>>n;
int l=s.size();
for(int i=0;i<l;i++){
if(s[i]==s[i+n])
a[count]=i;
count++;
}
for(int i=0;i<count;i++){
cout<<a[i]<<",";
}
return 0;
}