Replace all pi question

xpix
xabpixx3.15x
xpipippixx

what is the input given?
I dont understand the given input.

Basically the input given is your string values, that at some positions contains the keyword as “pi”. So wherever you get “pi”, you need to replace it by “3.14” and then you have to print the string…

#include
using namespace std;

void replacePI(string s,int i,int size)
{
if(i> size)
return ;

if(s[i]=='p')
{
	cout<<"3.14";
	i+=2;
}
cout<<s[i];
return replacePI(s,i+1,size);

}
int main() {
int n,i=0;
cin>>n;
while(i!=n)
{
string s;
cin>>s;
int l=s.length();
replacePI(s,0,l-1);
cout<<endl;
i++;
}
}

what is wrong with this code?

The approach you are following is wrong… Pls use this kind of approach as :
void replacepi(string str,string osf)
where str is input string and osf is " " …and then you can take as ,
if(str.length()==0)
{
cout<<osf;
return;
}
if(str.length()==1)
{
cout<<osf+str[0];
return;
}
if(str[0]==‘p’ && str[1]==‘i’)
{
replacepi(str.substr(2),osf+“3.14”);
}
else
{
replacepi(str.substr(1),osf+str[0]);
}