1 void exchange( struct node* node){ 2 struct node* tnode = node; 3 struct node* tmp = NULL; 4 5 if(node == NULL) 6 return; 7 8 while(1){ 9 tmp = tnode-> left; 10 tnode-> left = tnode->right ; 11 tnode-> right = tmp; 12 13 if(tnode->right ){ 14 push(tnode-> right); 15 } 16 17 if(tnode->left ){ 18 tnode = tnode->left; 19 } 20 else{ 21 if(!empty()){ 22 tnode = top(); 23 pop(); 24 } 25 else{ 26 break; 27 } 28 } 29 } 30 }
时间: 2024-11-03 22:32:21