I understood the logic but still not able to write the proper working code l..please help me i wrote this

In the question you have to find the maximum number of CB numbers that you can form from the input:
In the Sample Testcases:
Example 1:
5
81615
There are at max two CB numbers that we can form:
61
5
Thus, the output is 2.

Approach:

  1. check for all sub-strings of the given string of digits, starting from the all strings of length 1 and then gradually checking for the strings of increasing size:

1.1. check if the sub-string is CB number: for this, create a function
1.1.1. if sub-string is 1 or 0 return false.
1.1.2. if sub-string is any of the {2,3,5,7,11,13,17,19,23,29}, then return true.
1.1.3. if sub-string is divisible by any of the {2,3,5,7,11,13,17,19,23,29}, then return false.
1.1.4. return false

1.2. now if it is a substring:
1.2.1. call a function that marks the index as visited for indexes which are part of that CB number.

1.3. increment the count for CB number.

2. Print the count

Hope, this would help.
If you still have any issue, feel free to ask.
Give a like if you are satisfied.

Can u correct my code for this question

https://ide.codingblocks.com/s/314842 this is my code

you created a function named bool cb,
see your function definition

bool cb(char n) {
  for (int i = 0; i < 30; i++) {
    if (a(i)) {
      if ((n - 0) % i == 0) {
        return true;
      }
    }

  }
  return false;
}

and now see you function call:

if (cb(s.substr(i, j))) {
        c++;
        i = j - 1;
        break;
      }

you are giving a string in call and defined a char in definition.
Correct your approach.
Thanks.

i dont know how to typecast in c++ from one datatype to another can u please correct my ccode and tell me

you dont need to typecast here

See this code

Since you score 100 . so i am closing this doubt . you can reopen it if you have any queries.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.