#include <iostream>
using namespace std;

// Define UartConfig class here
// <write your code>
class UartConfig{
    private:
    int baudrate , parity, stopBits;
    public:
    
    UartConfig (int b1, int p1, int s1 )
    : baudrate(b1), parity(p1), stopBits(s1)   {}

    void update (int b, int p, int s)
    {
        this->baudrate = b;
        this->parity = p;
        this->stopBits = s;

    }

    void print()
    {
        std::cout <<"baud=" << baudrate 
                  <<" parity=" << parity
                  <<" stop=" << stopBits;
    }
};

int main() {
    int b1, p1, s1;
    int b2, p2, s2;

    cin >> b1 >> p1 >> s1;
    cin >> b2 >> p2 >> s2;

    UartConfig cfg(b1, p1, s1);
    cfg.update(b2, p2, s2);

    cfg.print();
    return 0;
}

Solving Approach

 

 

 

 

 

Upvote
Downvote
Loading...

Input

9600 0 1 115200 1 1

Expected Output

baud=115200 parity=1 stop=1