#include <bits/stdc++.h>
using namespace std;

struct node{
    int data;
    node* next;
};

struct node* head;

void inserth(int a){
    node* temp=new node();
    temp->data=a;
    temp->next=head;
    head=temp;
}

void reverse(){
    node *current,*prev,*nex;
    current=head;
    prev=NULL;
    
    while(current!=NULL){
        nex=current->next;
        current->next=prev;
        prev=current;
        current=nex;
    }
    head=prev;
    
}

void print(){
     node* temp1=head;
     while(temp1!=NULL){
         cout<<temp1->data<<" ";
         temp1=temp1->next;
     }
     cout<<endl;
 }

int main() {
    head=NULL;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        inserth(x);
    }
    print();
    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: