#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 100
typedef int ElemType;
typedef struct
{
ElemType *base, *top;
int capacity;
} Stack;
int InitStack(Stack *pstack)
{
pstack -> base = pstack -> top = (ElemType*)malloc(sizeof(ElemType) * MAXSIZE);
if(!pstack -> base)
return 0;
pstack -> capacity = MAXSIZE;
return 1;
}
int Push(Stack *pstack, ElemType e)
{
if(pstack -> top - pstack -> base >= pstack -> capacity)
{
pstack -> base = (ElemType*)realloc(pstack -> base, (pstack -> capacity + 10) * sizeof(ElemType));
pstack -> top = pstack -> base + pstack -> capacity;
pstack -> capacity += 10;
}
*(pstack -> top++) = e;
}
void Pop(Stack *pstack, ElemType *e)
{
*e = *(--pstack -> top);
}
int Empty(Stack *pstack)
{
return(pstack -> top - pstack -> base == 0);
}
int main()
{
int parameter, temp = 1, v;
Stack mStack;
InitStack(&mStack);
scanf("%d", ¶meter);
while(parameter >= 0)
{
if(parameter == 0)
{
Push(&mStack, parameter + 1);
break;
}
else
{
Push(&mStack, parameter);
}
parameter /= 2;
}
while(!Empty(&mStack))
{
Pop(&mStack, &v);
temp *= v;
}
printf("%d", temp);
return 0;
}
|