C语言高分
来源:百度知道 编辑:UC知道 时间:2024/05/11 19:51:22
看看这程序,不知道那而错了!
#include <stdio.h>
#include <string.h>
#define MaxSize 100
typedef struct
{
char s[MaxSize];
}ST;
ST *st;
int top=0;
void push(char *x,char *y);
char pop();
void translate();
void push(char *x,char *y) /*进栈*/
{
while((y+1)!=x)
st->s[top++]=*y--;
}
char pop() /*出*/
{
return(st->s[top--]);
}
void translate()
{
char e;
printf("\n");
while(top>=0)
{
e=pop();
if(e=='B') printf("tsaedsae");
else if(e=='A') printf("sae");
else if(e=='('||e==')') continue;
else printf("%c",e);
}
printf("\
#include <stdio.h>
#include <string.h>
#define MaxSize 100
typedef struct
{
char s[MaxSize];
}ST;
ST *st;
int top=0;
void push(char *x,char *y);
char pop();
void translate();
void push(char *x,char *y) /*进栈*/
{
while((y+1)!=x)
st->s[top++]=*y--;
}
char pop() /*出*/
{
return(st->s[top--]);
}
void translate()
{
char e;
printf("\n");
while(top>=0)
{
e=pop();
if(e=='B') printf("tsaedsae");
else if(e=='A') printf("sae");
else if(e=='('||e==')') continue;
else printf("%c",e);
}
printf("\
改后源程序如下:
#include <stdio.h>
#include <string.h>
#define MaxSize 100
typedef struct
{
char s[MaxSize];
}ST;
ST *st;
int top=0;
void push(char *x,char *y);
char pop();
void translate();
void push(char *x,char *y)
{
while((y+1)!=x)
st->s[top++]=*y--;
}
char pop()
{
return(st->s[top--]);
}
void translate()
{
char e;
printf("\n");
while(top>=0)
{
e=pop();
if(e=='B') printf("tsaedsae");
else if(e=='A') printf("sae");
else if(e=='('||e==')') continue;
else printf("%c",e);
}
printf("\n\nover!\n"); <