单链表的正序输出和逆序输出

#include #include using namespace std; typedef int elemtype; typedef struct LNode { elemtype data; struct LNode *next; }LNode,*Linklist; void creatlist(Linklist &L,elemtype A[],int n) { L=NULL; int i; for(i=n-1; i>=0; i--) { LNode *p=new LNode; p->data=https://www.it610.com/article/A[i]; p->next=L; L=p; } } voidxianshi(Linklist L) { LNode *p=L; while(p) { coutnext; s->next=L; L=s; } } int main() { int n,i; int a[100]; Linklist L; while(scanf("%d",&n)!=EOF) { for(i=0; i>a[i]; creatlist(L,a,n); xianshi(L); cout<

【单链表的正序输出和逆序输出】转载于:https://www.cnblogs.com/NYNU-ACM/p/4236865.html

    推荐阅读