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

int main() {
    int N;
    cin >> N;

    {
        // Declare a unique_ptr to manage a dynamic integer buffer
        // Allocate memory for N integers
        auto p=std::make_unique<int[]>(N);
        for(int i=0;i<N;i++)
        {
            cin>>p[i];
        }

     /*   for (int i = 0; i < N; i++) {
            int temp;
            cin >> temp;
            // Store value in the buffer
            p[i]=temp;
        }*/

        for (int i = 0; i < N; i++) {
            // Print buffer values
            cout<<p[i];
            if (i != N - 1) cout << " ";
        }
        cout << endl;
    }

    cout << "Scope ended" << endl;
    return 0;
}

Solving Approach

 

 

 

 

 

Upvote
Downvote
Loading...

Input

1 0

Expected Output

0 Scope ended