What is the error

#include<bits/stdc++.h>
using namespace std;

void pi(int n,int i=0){
char a[10000];
cin>>a;
for(int k=1;k<=n;k++){

if(a[i]=='\0' || a[i+1]=='\0'){
	return;
}
if(a[i]=='p' && 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';
	pi(n,i+4);
}
else{
	pi(n,i+1);
}

}
cout<<a<<endl;
}
int main() {
int n;
cin>>n;
pi(n);
return 0;
}

you code is not correct
n is no testcases means no of inputs given to you and corresponding to each input you have to print output
if n =3 then you have to take 3 inputs and print 3 output
but you are taking input only once that is first mistake

Correct way to doing

#include<iostream>
using namespace std;
void solve(char ch[], int i, char out[], int j) {
	if (ch[i] == '\0') {
		cout << out << endl;
		return;
	}

	if (ch[i] == 'p' && ch[i+1] == 'i') {
		out[j] = '3';
		out[j + 1] = '.';
		out[j + 2] = '1';
		out[j + 3] = '4';
		solve(ch, i + 2, out, j + 4);
	} else {
		out[j] = ch[i];
		solve(ch, i + 1, out, j + 1);
	}
}
int main() {
	int t;
	cin >> t;
	while (t--) {
		// take input
		char ch[10000], out[10000];
		cin >> ch;

		// print output corresponding to given input
		solve(ch, 0, out, 0);
	}

	return 0;
}

is your doubt resolved ??
or you need more assistance