C # count the number of "0" characters and insert the number into the characters. Requirements:
Input:
Rnbakabnr/000000000/0 c00000c0/p0p0p0p0p/000000000/000000000/p0p0p0p0p/0c00000c0/000000000/rnbakabnr
Output:
Rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/p1p1p1p1p/1c5c1/9/rnbakabnr
Answer:
// RecursionAlgorithm
Private string prossstr (string tempstr)
{
String tempall = "";
Int J0 = tempstr. indexof ('0 ');
If (J0>-1)
{
Int J1 = 0;
For (INT I = 0; I <tempstr. Length-J0; I ++)
{
String k2 = tempstr. substring (J0 + I, 1 );
If (k2 = "0 ")
{
J1 = J1 + 1;
}
Else
{
Break;
}
}
String tempstr1 = tempstr. Remove (J0, J1). insert (J0, j1.tostring ());
Tempall = prossstr (tempstr1 );
}
Else
{
Tempall = tempstr;
}
Return tempall;
}
Call:
String tempstrall = "";
String S = "rnbakabnr/000000000/0 c00000c0/p0p0p0p0p/000000000/000000000/p0p0p0p0p/0c00000c0/000000000/rnbakabnr"; // enter
Tempstrall = prossstr (s); // execute the algorithm
Output to the variable tempstrall:
Rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/p1p1p1p1p/1c5c1/9/rnbakabnr