#include "stdio.h"
#include "SeqStack.h"
int StackSum(SeqStack *s) //求和
{
int x=0;
int sum = 0;
while (StackNotEmpty(*s))
{
StackPop(s, &x);
sum += x;
}
return sum;
}
int main()
{
SeqStack s;
StackInitiate(&s);
StackPush(&s, 1);
StackPush(&s, 2);
printf("sum= %d", StackSum(&s));
return 0;
}
//运行结果:sum=3