Error Time limit exceeded

code:
#include
using namespace std;
void replacePi(char *a,int i){
//base case
if(a[0]==’\0’ and a[1]==’\0’){
return;
}
//recursive
if(a[i]==‘p’ and a[i+1]==‘i’){
int j=i+2;
while(j!=’\0’){
j++;
}
while(j>=i+2){
a[j+2]=a[j];
j–;
}
a[i]=‘3’;
a[i+1]=’.’;
a[i+2]=‘1’;
a[i+3]=‘4’;
replacePi(a,i+4);
}
else{
replacePi(a,i+1);
}
}
int main(){
char a[1000];
int q;
cin>>q;
for(int i=0;i<q;i++){
cin.getline(a,100);
replacePi(a,0);
cout<<a<<endl;
}

return 0;

}

@anshita_1312 submit this code once so that i can get it in the backend

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.