#include <stdio.h>
#include <string.h>
#include "STACK.h"
int main(int argc, char *argv[])
{
char *a = argv[1]; int i, N = strlen(a);
STACKinit(N);
for (i = 0; i < N; i++)
{
if (a[i] == ')')
printf("%c ", STACKpop());
if ((a[i] == '+') || (a[i] == '*'))
STACKpush(a[i]);
if ((a[i] >= '0') && (a[i] <= '9'))
printf("%c ", a[i]);
}
printf("\n");
return 0;
}
|
其中STACKpush,STACKpop,STACKinit为对下推栈的操作函数
阅读(1869) | 评论(0) | 转发(0) |