Code is compiling but test case failed

int replace(string a,int i)
{
if(i>a.length())
{
cout<<endl;
return 0;
}
else if(a[i]==β€˜p’ && a[i+1]==β€˜i’)
{
cout<<β€œ3.14”;
i=i+1;
}

else if(a[i]!='p')
{
	cout<<a[i];
}	
replace(a,i+1);

}

int main()
{
// cout<<β€œenter the no of lines:”;
int k;
cin>>k;
if(k>0 && k<1000)
{

string b[k];
for(int i=0;i<3;i++)
{

// cout<<β€œEnter the line:”;
string a;
cin>>a;
if(a.length()>=0 && a.length()<1000)
b[i]=a;
}
for(int i=0;i<k;i++)
{

	replace(b[i],0);
}

}	

}

Hi @manseerat, you are taking Inputs in wrong way you don;t have to check for constraints , constraints are given so that you can devise appropriate algo base on constraints . also you have to check for some corner cases like when i+1 is >=sizeof(str) ,single digit numbers etc.

you can refer to this code to get the hint