Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- string print(string s, int i, int j){
- if(j == s.length()){
- return s;
- }
- if(s[i] =='p' && s[j] == 'i' ){
- s.replace(i,2,"3.14");
- }
- return print(s, i + 1, j + 1);
- }
- int main(){
- int n;
- cin>>n;
- while(n--){
- string s;
- cin>>s;
- cout<<print(s,0,1)<<endl;
- }
- return 0;
- }
- x3.14x
- xab3.14xx3.15x
- x3.143.14p3.14xx
Add Comment
Please, Sign In to add comment