Guest User

Untitled

a guest
Dec 27th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4. string print(string s, int i, int j){
  5.  
  6.     if(j == s.length()){
  7.         return s;
  8.     }
  9.     if(s[i] =='p' && s[j] == 'i' ){
  10.         s.replace(i,2,"3.14");
  11.     }
  12.     return print(s, i + 1, j + 1);
  13.    
  14. }
  15.  
  16. int main(){
  17.     int n;
  18.     cin>>n;
  19.     while(n--){
  20.         string s;
  21.         cin>>s;
  22.         cout<<print(s,0,1)<<endl;
  23.     }
  24.     return 0;
  25. }
  26. x3.14x
  27. 
xab3.14xx3.15x

  28. x3.143.14p3.14xx
Add Comment
Please, Sign In to add comment