编辑代码

#include <stdio.h>
#define M (1000+5)
typedef char ElemType;

typedef struct
{
	ElemType data[M];
	int top;
}SqStack;

void init(SqStack *s);
int isEmpty(SqStack s);
int isFull(SqStack s);
int push(SqStack *s,ElemType item);
int pop(SqStack *s,ElemType *item);
int getTop(SqStack *s,ElemType *item);
int NToR(int n,int r);

int main()
{
	SqStack s;
	init(&s);
	ElemType x;
	while(~scanf("%c",&x))
	{
		if(x >= 'a' && x <= 'z')
			push(&s,x);
	}
	while(!isEmpty(s))
	{
		pop(&s,&x);
		printf("%c ",x);
	}

	return 0;
}

void init(SqStack *s)
{
	s -> top = -1;
}

int isEmpty(SqStack s)
{
	if(s.top == -1)
		return 1;
	else
		return 0;
}

int isFull(SqStack s)
{
	if(s.top == M -1)
		return 1;
	else
		return 0;	
}

int push(SqStack *s,ElemType item)
{
	if(isFull(*s))
		return 0;
	s -> top++;
	s -> data[s -> top] = item;
	return 1;
}

int pop(SqStack *s,ElemType *item)
{
	if(isEmpty(*s))
		return 0;
	*item = s -> data[s->top];
	s->top--;
	return 1;
}

int getTop(SqStack *s,ElemType *item)
{
	if(isEmpty(*s))
		return 0;
	*item = s->data[s->top];
	return 1;
}

int NToR(int n,int r)
{
    SqStack s;
	int t;
    char a;
	while(n != 0)
	{
		t = n%r;
		if(t >= 10)
            a = 'A' + (t-10);
        else
            a = '0' + t;
        push(&s,a);
        n /= r;
	}
    while(!isEmpty)
    {
        pop(&s,&a);
    }
}