Given two strings like x=?hello? and y=?open?, remove any
character from string x which is also used in string y,
thus making the result x=?hll?.
Answer Posted / newpolaris
bool IsInStr(char ch, const std::string& B)
{
return std::string::npos != B.find(ch);
}
// act fuction
std::string remove_same_char(const std::string& A, const
std::string& B)
{
typedef std::string::const_iterator cstr_const_it;
cstr_const_it iCSTR = A.begin();
// FOR OPTIMIZATION NRVO IS NEEDED
// ? IS POSSIBLE?
std::string _rt;
while ( iCSTR != A.end() )
{
if (!IsInStr(*iCSTR,B)) _rt+=*iCSTR;
iCSTR++;
}
return _rt;
}
int main()
{
std::string x = "hello";
const std::string y = "open";
x = remove_same_char(x, y);
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Whats is abstraction in oops?
given a set based questions and 5 questions based on it next data sufficiciency questions 2 and 2/3 english sentence completion with options very easy and 2 synononmys paragraph with 10 questions 10 minutes replace =,-,*,% with -,%,+,* type questions 5 3 questions lik following itssickhere itssickthere itssickhere istsickhere which is nt alike the others very easy
How oops is better than procedural?
How is class defined?
design a c++ class for the chess board,provide a c++ class definition for such class(only class definition is required)
What is a class and object?
How long to learn object oriented programming?
What is an example of genetic polymorphism?
Which language is not a true object oriented programming language?
What are main features of oop?
I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...
i=20;k=0;
for(j=1;k-i;k+=j<10?4:3)
{
cout< Why is oop better than procedural? What is a class oop? Can abstract class have normal methods?