PROBLEM:-
Replace pi (recursive)
Send Feedback
xpix
x3.14x
pipi
3.143.14
pip
3.14p
SOLUTION:-
#include <iostream>
using namespace std;
#include<string.h>
void replacePi(char input[]) {
if(input[0]=='\0')
return;
replacePi(input+1);
if(input[0]=='p'&&input[1]=='i')
{
int l=strlen(input);
int i=l;
while(i>=2)
{
input[i+2]=input[i];
i--;
}
input[0]='3';
input[1]='.';
input[2]='1';
input[3]='4';
replacePi(input+4);
}
}
int main() {
char input[10000];
cin.getline(input, 10000);
replacePi(input);
cout << input << endl;
}
This is dummy text. It is not meant to be read. Accordingly, it is difficult to figure out when to end it. But then, this is dummy text. It is not meant to be read. Period.
If you have any doubts then please let me know... ConversionConversion EmoticonEmoticon