Dynamic SensorData Allocation

#include <iostream>
using namespace std;

// Write your struct and dynamic allocation code here
struct SensorData {
    int x;
    int y;
    int z;
    SensorData(int x_, int y_, int z_) : x(x_), y(y_), z(z_) {};
};
int main() {
    int x, y, z;
    cin >> x >> y >> z;

    // Write your dynamic allocation logic here
    struct SensorData *sd = new SensorData(x, y, z);
    cout << sd->x << " " << sd->y << " " << sd->z << endl;
    delete sd;
    return 0;
}

Solving Approach

 

 

 

 

 

 

Upvote
Downvote
Loading...

Input

3 4 5

Expected Output

3 4 5