#includestructListNode{intdata=0;ListNode*next=NULL;};//反向链表//标题:反向单向链表。//例子:输入:1->2->3->4->5->NULL输出:5->4->3->2->1->NULLclassSolution{public:ListNode*reverseList(ListNode*head){ListNode*temp;列表节点*cur=head;列表节点*pre=NULL;while(cur){//保存下一个节点temp=cur->next;//next指向头节点cur->next=pre;//头节点向下移动pre=cur;//下一个节点向下移动cur=temp;}返回前;}};intmain(){返回0;}