#include <iostream>
#include <cstdint>
using namespace std;

// Define ByteBuffer class with operator[]
class ByteBuffer {
private:
    uint8_t data[8];

public:
    uint8_t& operator[](int index) {
        return data[index];
    }

    uint8_t operator[](int index) const {
        return data[index];
    }
};
int main() {
    ByteBuffer buffer;

    for (int i = 0; i < 8; i++) {
        int x;
        cin >> x;
        buffer[i] = x;
    }

    int idx, v;
    cin >> idx >> v;

    buffer[idx] = v;

    for (int i = 0; i < 8; i++) {
        cout << (int)buffer[i] << (i == 7 ? "" : " ");
    }

    return 0;
}

Solving Approach

 

 

 

 

Upvote
Downvote
Loading...

Input

1 2 3 4 5 6 7 8 3 99

Expected Output

1 2 3 99 5 6 7 8