#include<iostream> struct node{ int payload; node* next; }; void bianli(node* head){ node* iterator = head; while(iterator){ std::cout << iterator->payload<<" "; iterator = iterator->next; } std::cout<<" "<<std::endl; } node* whilefunc(node* head){ if(head==nullptr|| head->next==nullptr) return head; node* p = head->next; node* p_previous = head; p_previous->next = nullptr; while(p!=nullptr){ node* p_next = p->next; p->next = p_previous; p_previous = p; p = p_next; } return p_previous; } int main(){ node* head = nullptr; for(int i=0;i<10;i++){ node* new_node = new node; new_node->payload = i*10; new_node->next=head; head = new_node; } head = whilefunc(head); bianli(head); system("pause"); return 0; }