#include <iostream>
#include <cstdint>

using namespace std;

using Packet = uint8_t[8];
// 1. Create the alias for an array of 8 bytes:
// using Packet = ...

int main() {
    Packet p8;
    uint32_t temp[8];
    for(int i =0; i<8; i++){
        std::cin>>temp[i];
    }
    for(int i = 0; i<8; i++ ){
        p8[i]= static_cast<uint8_t>(temp[i]);
    }
    for(int i = 0; i<8; i++){
        std::cout<<static_cast<uint32_t>(p8[i])<<" ";
    }
    // 2. Declare a variable of type Packet and a temporary int array
    
    // 3. Read 8 integers into the temporary array
    
    // 4. Assign values to the Packet buffer using static_cast<uint8_t>
    
    // 5. Print values as numbers with space separation (no trailing space)
    
    return 0;
}

Solving Approach

 

 

 

 

 

Upvote
Downvote
Loading...

Input

10 20 30 40 50 60 70 80

Expected Output

10 20 30 40 50 60 70 80