i ddin’t get the line from 17 to 20…please explain me
#include
#include
using namespace std;
void replace(char *a, int i)
{
// base case
if (a[i] == ‘\0’ || a[i + 1] == ‘\0’)
{
return;
}
// recursive case
if (a[i] == 'p' && a[i + 1] == 'i')
{
int j = i + 2;
while (a[j] != '\0')
{
j++;
}
while (j >= i + 2)
{
a[j + 2] = a[j];
j--;
}
// copy the pi
a[i] = '3';
a[i + 1] = '.';
a[i + 2] = '1';
a[i + 3] = '4';
// ask the recursion to solve the samller string
replace(a, i + 4);
}
else
{
// ask the recursion to solve the smaller string
replace(a, i + 1);
}
}
int main()
{
char a[100];
cin.getline(a, 100);
int n = strlen(a);
cout << a << endl;
replace(a, 0);
cout << a << endl;
return 0;
}