手撕单链表创建并反转全过程
#include <bits/stdc++.h>
using namespace std;
struct node{
int val;
struct node * next;
node(){} ///空参构造器
node(int x) : val(x), next(NULL){} ///带参构造器
};
int main() {
int n;
scanf("%d", &n);
node* dummy = new node; ///dummy表示头节点
n
原创
2022-01-20 14:12:20 ·
691 阅读 ·
0 评论