#include <iostream>
#include <cstdint>
#include <new>
#include <type_traits>
using namespace std;
typedef struct{
int id;
int value;
}SensorPacket;
// Write your struct and placement new logic here
int main() {
int index, id, value;
cin >> index >> id >> value;
// Properly aligned memory pool for 3 SensorPacket objects
using Storage = std::aligned_storage_t<
sizeof(SensorPacket),
alignof(SensorPacket)
>;
Storage pool[3];
// Construct packet inside chosen pool slot
SensorPacket* p = new (&pool[index]) SensorPacket{ id, value };
cout << p->id << " " << p->value;
// Manual destructor call
p->~SensorPacket();
return 0;
}
Input
1 50 900
Expected Output
50 900