复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37#include <iostream> using namespace std; typedef struct LNode{ int data; struct LNode *next; }LNode; int createlistR(LNode *&C,int a[],int n){ LNode *s,*r; int i; C=(LNode*)malloc(sizeof(LNode)); C->next=NULL; r=C; for(i=0;i<n;++i){ s=(LNode*)malloc(sizeof(LNode)); s->data=a[i]; r->next=s; r=r->next; } r->next=NULL; for(i=0;i<n;++i){ cout<<a[i]; } return 1; } int main() { LNode *C; int n=5; int a[5]={1,2,3,4,5}; createlistR(C,a,n); return 0; }
最后
以上就是兴奋月光最近收集整理的关于尾插法建立单链表并输出单链表。的全部内容,更多相关尾插法建立单链表并输出单链表内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复