#include<iostream> #include<fstream> #include<cstdio> #include<cmath> #include<string> #include<cstring> #include<string.h> #include<algorithm> #include <cstdlib> using namespace std; struct node { int data; struct node *next; }; int main(){ struct node *head,*p,*q; head = nullptr; int n; cin >> n; int tem; for(int i = 0;i < n;i++){ p = (struct node *) malloc(sizeof(struct node)); cin >> p->data; p->next = nullptr; if(head == nullptr){ head = p; }else{ q->next = p; } q = p; } }