Skip to content

Commit

Permalink
Merge pull request 0voice#54 from xiepeiyang/master
Browse files Browse the repository at this point in the history
修复1.1.1答案错误
  • Loading branch information
wangbojing authored Oct 16, 2019
2 parents 41b3343 + d36dcba commit 400e286
Showing 1 changed file with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,26 @@ typedef struct node{
void reverse(node* head)
{
if(NULL == head || NULL == head->next){
if(head == NULL){
return;
}
node* prev=NULL;
node* pcur=head->next;
node* next;
while(pcur!=NULL){
if(pcur->next==NULL){
pcur->next=prev;
break;
}
next=pcur->next;
pcur->next=prev;
prev=pcur;
pcur=next;
node* pleft = NULL;
node* pcurrent = head;
node* pright = head->next;
while(pright){
pcurrent->next = pleft;
node *ptemp = pright->next;
pright->next = pcurrent;
pleft = pcurrent;
pcurrent = pright;
pright = ptemp;
}
head->next=pcur;
node*tmp=head->next;
while(tmp!=NULL){
cout<<tmp->data<<"\t";
tmp=tmp->next;
while(pcurrent != NULL){
cout<< pcurrent->data << "\t";
pcurrent = pcurrent->next;
}
}
Expand Down

0 comments on commit 400e286

Please sign in to comment.