Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct St_node
- {
- int x;
- St_node* next;
- };
- struct Node
- {
- char *s;
- St_node* st;
- Node* next;
- };
- void rewrite_stack(Node* &a)
- {
- St_node* current1 = a->next->st;
- St_node* current2 = a->st;
- while (current2 != NULL)
- {
- St_node* tmp = current2->next;
- current2->next = current1;
- current1 = current2;
- current2 = tmp;
- }
- }
- void func(Node* &head)
- {
- int max_l = -1;
- Node* max_node = NULL;
- Node* current = head;
- do
- {
- if (strlen(current->s) > max_l)
- {
- max_node = current;
- max_l = strlen(current->s);
- }
- } while (head != current);
- rewrite_stack(max_node);
- current = head;
- while (current->next != max_node)
- current = current->next;
- Node* tmp = max_node->next;
- free(current->next);
- current->next = tmp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement