Code related problem

how to find string with length 1 and two and so on and simultaneously if that substring is CB then i want to remove that from string.
please help me to find different substring.

Share your code that you have done until now

#include <bits/stdc++.h> #include using namespace std; bool is_cb(int x) { int flag=0; int div[]={2,3,5,7,11,13,17,19,23,29}; for(int i=0;i<10;i++) { if(x==div[i]) { flag++; break; } } int cb=0; if(flag==0) { for(int i=0;i<10;i++) { if(x%div[i]==0 && x!=0) { cb++; } } } if(flag==1) { //cout<<x<<endl; return 1; } else if(cb==0 && flag==0) { //cout<<x<<endl; return 1; } else { return 0; } } int main() { int n; cin>>n; string s,ans="",che=""; cin>>s; int count=0; int div[]={2,3,5,7,11,13,17,19,23,29}; int answer=0; for(int i=0;i<s.length();i++) { for(int j=i;j<s.length();j++) { ans+=s[j]; if(is_cb(stoi(ans))) { //cout<<ans<<endl; answer++; s.erase(i,j-i); } } ans.clear(); } cout<<answer; return 0; }

Bro please share on ide how can I find error in this paragraph