#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct el_stack {
char symbol;
struct el_stack * new;
};
typedef struct el_stack *p_el_stack;
void push(p_el_stack *head, char x)
{
p_el_stack tmp
= (p_el_stack
)malloc(sizeof(struct el_stack
)); tmp->symbol = x;
tmp->new = *head;
*head = tmp;
}
char pop (p_el_stack *head)
{
char resymb;
p_el_stack tmp = *head;
resymb = tmp->symbol;
*head = tmp->new;
return(resymb);
}
int main(void) {
char str[255];
p_el_stack *stack;
int i,j;
for(i
=0; i
<strlen(str
); i
++) push
(&stack
, str
[i
]); for(j=0; j<i; j++) str[j]=pop(&stack);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0cmluZy5oPgoKc3RydWN0IGVsX3N0YWNrIHsKCWNoYXIgc3ltYm9sOwoJc3RydWN0IGVsX3N0YWNrICogbmV3Owp9OwoKdHlwZWRlZiBzdHJ1Y3QgZWxfc3RhY2sgKnBfZWxfc3RhY2s7Cgp2b2lkIHB1c2gocF9lbF9zdGFjayAqaGVhZCwgY2hhciB4KQp7CglwX2VsX3N0YWNrIHRtcCA9IChwX2VsX3N0YWNrKW1hbGxvYyhzaXplb2Yoc3RydWN0IGVsX3N0YWNrKSk7Cgl0bXAtPnN5bWJvbCA9IHg7Cgl0bXAtPm5ldyA9ICpoZWFkOwoJKmhlYWQgPSB0bXA7Cn0KCmNoYXIgcG9wIChwX2VsX3N0YWNrICpoZWFkKQp7CgljaGFyIHJlc3ltYjsKCXBfZWxfc3RhY2sgdG1wID0gKmhlYWQ7CglyZXN5bWIgPSB0bXAtPnN5bWJvbDsKCSpoZWFkID0gdG1wLT5uZXc7CglmcmVlKHRtcCk7CglyZXR1cm4ocmVzeW1iKTsKfQoKCmludCBtYWluKHZvaWQpIHsKCWNoYXIgc3RyWzI1NV07CglwX2VsX3N0YWNrICpzdGFjazsKCWZnZXRzKHN0ciwyNTUsc3RkaW4pOwoJaW50IGksajsKCWZvcihpPTA7IGk8c3RybGVuKHN0cik7IGkrKykgcHVzaCgmc3RhY2ssIHN0cltpXSk7Cglmb3Ioaj0wOyBqPGk7IGorKykgc3RyW2pdPXBvcCgmc3RhY2spOwoJcHJpbnRmKCIlc1xuIixzdHIpOwoJcmV0dXJuIDA7Cn0=