#include <iostream>
using namespace std;
class node{
public:
int data;
node* next;
};
node* head;
node* tail;
void create(){
int n,val;
cin>>n;
for(int i=0;i<n;i++){
cin>>val;
node* temp = new node();
temp->data = val;
if(i==0){
temp->next=NULL;
head = tail = temp;
}
else{
tail->next = temp;
tail = temp;
}
}
}
void print(){
node* ptr = head;
while(ptr != NULL){
cout<<ptr->data<<"->";
ptr=ptr->next;
}
cout<<"NULL";
}
int main() {
create();
print();
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: