typedefint QueueData;typedefstructQueueNode{
QueueData data;structQueueNode* next;}QueueNode;typedefstruct{
QueueNode* front;
QueueNode* back;} MyStack;
MyStack*myStackCreate(){
MyStack* obj =malloc(sizeof(MyStack));
QueueNode* head =malloc(sizeof(QueueNode));
head -> next =NULL;
obj -> front = head;
obj -> back = head;return obj;}voidmyStackPush(MyStack* obj,int x){
QueueNode* tmp =malloc(sizeof(QueueNode));
obj -> back -> next = tmp;
obj -> back = tmp;
obj -> back -> data = x;
obj -> back -> next =NULL;}intmyStackPop(MyStack* obj){
QueueNode* record = obj -> back;while(obj -> front -> next != record){
obj -> back -> next = obj -> front -> next;
obj -> back = obj -> front -> next;
obj -> front -> next = obj -> front -> next -> next;
obj -> back -> next =NULL;}
record = obj -> front -> next;
obj -> front -> next = record -> next;
obj -> back = obj -> front -> next ==NULL? obj -> front : obj -> back;
QueueData result = record -> data;free(record);return result;}intmyStackTop(MyStack* obj){
QueueNode* record = obj -> back;while(obj -> front -> next != record){
obj -> back -> next = obj -> front -> next;
obj -> back = obj -> front -> next;
obj -> front -> next = obj -> front -> next -> next;
obj -> back -> next =NULL;}
QueueData result = obj -> front -> next -> data;
obj -> back -> next = obj -> front -> next;
obj -> back = obj -> front -> next;
obj -> front -> next = obj -> front -> next -> next;
obj -> back -> next =NULL;return result;}
bool myStackEmpty(MyStack* obj){return obj -> front -> next ==NULL;}voidmyStackFree(MyStack* obj){while(obj -> front -> next !=NULL){
QueueNode* tmp = obj -> front -> next;
obj -> front -> next = obj -> front -> next -> next;free(tmp);}free(obj -> front);free(obj);}