#include <iostream> #include <cstdint> #include <new> using namespace std; // Write your struct and placement new logic here typedef struct{ int level; }Mode; int main() { int firstLevel, secondLevel; cin >> firstLevel >> secondLevel; // Write your in-place reinitialization logic here alignas(Mode) uint8_t buf[sizeof(Mode)]; Mode* p=new (buf) Mode{firstLevel}; p->~Mode(); p=new (buf) Mode{secondLevel}; cout<<p->level; p->~Mode(); return 0; }
Test Cases
Test Results
Input
3 9
Expected Output
9