Write the program to replace pi with 3.14 in string. input = pippdfpig output = 3.14ppdf3.14g

 


#include<iostream>
using namespace std;
void removepi(string a)
   {if(a.size()==0)
        {return ;}
   
   if(a[0]=='p' && a[1]=='i')
     {cout<<"3.14";
      removepi(a.substr(2));}
      else {cout<<a[0];
       removepi(a.substr(1));}        
    }

int main()
{
    string a;
     a="pippdfpig";
    removepi(a);
    return 0;
}

Comments

Popular posts from this blog

Write the program to determine the maximum possible way to reach the end from starting in game board.

FALSE POSITION METHOD

Write the program to arrange the n queen(queen of chessboard) in n*n matrix such that they can not ATTACK TO eachother.