#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 insertt(int a){
    node* temp=new node();
    temp->data=a;
    if(head==NULL){
        temp->next=head;
        head=temp;
    }else{
        node* current=head;
        while(current->next!=NULL){
            current=current->next;
        }
        current->next=temp;
    }
    
}
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;
        insertt(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: