Create a new string from a give string where a specified character have been removed except starting and ending position of the given string
- برمجة سي بلس بلس
- برمجة
- 2021-05-11
- MarwaMohammed
الأجوبة
#include <iostream>
using namespace std;
string test(string str1, string c)
{
for (int i = str1.length() - 2; i > 0; i--)
{
if (str1[i] == c[0])
{
str1 = str1.erase(i, 1);
}
}
return str1;
}
int main()
{
cout << test("xxHxix", "x") << endl;
cout << test("abxdddca", "a") << endl;
cout << test("xabjbhtrb", "b") << endl;
return 0;
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
