Untitled

 avatar
user_5811307
plain_text
22 days ago
688 B
1
Indexable
Never
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

string g(string a, char x1, char x2)
{
    for(int i =0; i < a.length();i++)
    {
        if(a[i] == x1)
        {
            a[i] = x2;
        }
    }
    return a;
}

int main()
{
    string a;
    char x1,x2;
    cin >> a >> x1 >> x2;

    cout << g(a,x1,x2);
}#include <iostream>
#include <cmath>
#include <string>
using namespace std;

string g(string a, char x1, char x2)
{
    for(int i =0; i < a.length();i++)
    {
        if(a[i] == x1)
        {
            a[i] = x2;
        }
    }
    return a;
}

int main()
{
    string a;
    char x1,x2;
    cin >> a >> x1 >> x2;

    cout << g(a,x1,x2);
}
Leave a Comment