#include <stdio.h>
#include <malloc.h>
#include <string.h>
struct Stack {
int capacity;
char *arr;
int top;
};
struct Stack* createStack(unsigned capacity) {
struct Stack
*s
= (struct Stack
*)malloc(sizeof(struct Stack
)); s->capacity = capacity;
s->top = -1;
s
->arr
= (char*)malloc(capacity
* sizeof(char)); return s;
};
int isFull(struct Stack *stack) {
return stack->top == stack->capacity - 1;
};
int isEmpty(struct Stack *stack) {
return stack->top == -1;
};
void push(struct Stack* stack, int data) {
if(isFull(stack)) {
return;
}
stack->arr[++stack->top] = data;
}
char pop(struct Stack *stack) {
if(isEmpty(stack)) {
return 0;
}
return stack->arr[stack->top--];
}
char* reverse(char *p, int n) {
struct Stack *stack = createStack(n);
for(int i = 0; i < n; ++i) {
push(stack, p[i]);
}
for(int i = 0; i < n; ++i) {
}
};
int main(int argc, char const *argv[]) {
char str[100] = "MayAnnCampanera";
reverse(str,n);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYWxsb2MuaD4KI2luY2x1ZGUgPHN0cmluZy5oPgoKc3RydWN0IFN0YWNrIHsKICAgIGludCBjYXBhY2l0eTsKICAgIGNoYXIgKmFycjsKICAgIGludCB0b3A7Cn07CgpzdHJ1Y3QgU3RhY2sqIGNyZWF0ZVN0YWNrKHVuc2lnbmVkIGNhcGFjaXR5KSB7CiAgICAgc3RydWN0IFN0YWNrICpzID0gKHN0cnVjdCBTdGFjayopbWFsbG9jKHNpemVvZihzdHJ1Y3QgU3RhY2spKTsKICAgICAgICAgICAgcy0+Y2FwYWNpdHkgPSBjYXBhY2l0eTsKICAgICAgICAgICAgcy0+dG9wID0gLTE7CiAgICAgICAgICAgIHMtPmFyciA9IChjaGFyKiltYWxsb2MoY2FwYWNpdHkgKiBzaXplb2YoY2hhcikpOwogICAgICAgICAgICByZXR1cm4gczsKfTsKCmludCBpc0Z1bGwoc3RydWN0IFN0YWNrICpzdGFjaykgewogICAgcmV0dXJuIHN0YWNrLT50b3AgPT0gc3RhY2stPmNhcGFjaXR5IC0gMTsKfTsKCmludCBpc0VtcHR5KHN0cnVjdCBTdGFjayAqc3RhY2spIHsKICAgIHJldHVybiBzdGFjay0+dG9wID09IC0xOwp9OwoKdm9pZCBwdXNoKHN0cnVjdCBTdGFjayogc3RhY2ssIGludCBkYXRhKSB7CiAgICAgIGlmKGlzRnVsbChzdGFjaykpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgc3RhY2stPmFyclsrK3N0YWNrLT50b3BdID0gZGF0YTsKfQoKY2hhciBwb3Aoc3RydWN0IFN0YWNrICpzdGFjaykgewogICAgICBpZihpc0VtcHR5KHN0YWNrKSkgewogICAgICAgIHByaW50ZigiaXNFbXB0eSIpOwogICAgICAgIHJldHVybiAwOwogICAgICB9CiAgICAgIHJldHVybiBzdGFjay0+YXJyW3N0YWNrLT50b3AtLV07Cn0KCmNoYXIqIHJldmVyc2UoY2hhciAqcCwgaW50IG4pIHsKCiAgICAgIHN0cnVjdCBTdGFjayAqc3RhY2sgPSBjcmVhdGVTdGFjayhuKTsKCiAgICAgICAgICAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgKytpKSB7CiAgICAgICAgICAgICAgICBwdXNoKHN0YWNrLCBwW2ldKTsKICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgKytpKSB7CiAgICAgICAgICAgICAgICAgcHJpbnRmKCIlYyIsIHBvcChzdGFjaykpOwogICAgICAgICAgICAgfSAgICAgICAgICAgICAKfTsKCmludCBtYWluKGludCBhcmdjLCBjaGFyIGNvbnN0ICphcmd2W10pIHsKICBjaGFyIHN0clsxMDBdID0gIk1heUFubkNhbXBhbmVyYSI7CiAgaW50IG4gPSBzdHJsZW4oc3RyKTsKICByZXZlcnNlKHN0cixuKTsKICByZXR1cm4gMDsKfQ==