标签:pac using cout int 反转 reverse div stream 单链表反转
#include <iostream> #include <vector> #include <string> using namespace std; struct Node { int data; Node * next; }; Node * reverseList(Node * head) { Node * pre = nullptr; Node * cur = head; Node * next = nullptr; while (cur) { next = cur->next; cur->next = pre; pre = cur; cur = next; } return pre; } int main() { Node * a = new Node();; a->data = 1; Node * b = new Node(); b->data = 2; a->next = b; b->next = nullptr; Node * head = reverseList(a); while (head) { cout<<head->data<<endl; head = head->next; } cout << "hello" << endl; return 0; }
标签:pac using cout int 反转 reverse div stream 单链表反转
原文地址:https://www.cnblogs.com/wlqsmiling/p/14252079.html