Untitled
unknown
c_cpp
2 years ago
451 B
5
Indexable
#include <iostream>
#include <string>
void replace(std::string& str, char el, char newel) {
for (int i = 0; i < str.length(); i++) {
if (str[i] == el) {
str[i] = newel;
}
}
}
int main()
{
std::string str;
char el, newel;
std::cin >> str >> el >> newel;
replace(str, el, newel);
for (int i = 0; i < str.length(); i++) {
std::cout << str[i];
}
}
Editor is loading...
Leave a Comment