void creatlist(linklist &l, int n){
l = new node();
l -> next = NULL;
while (int i = 1; i <= n; i++){
p = new node();
cin >> p -> data;
p -> next = l -> next;
l -> next = p;
}
}
逆序建立单链表
最新推荐文章于 2023-05-03 11:09:38 发布
void creatlist(linklist &l, int n){
l = new node();
l -> next = NULL;
while (int i = 1; i <= n; i++){
p = new node();
cin >> p -> data;
p -> next = l -> next;
l -> next = p;
}
}