帮忙看下这程序怎样改,急!!!!
来源:百度知道 编辑:UC知道 时间:2024/05/08 01:00:01
这程序能否改成含有分步计算结果的程序??就是3+5-6
(1)8
(2)2
这样分步显示每次计算的结果。就在原程序上改写在下面。
#include<stdio.h>
#include<malloc.h>
#include<string.h>
typedef struct Fnode/*符号单链表*/
{
int yxj;
char fh;
struct Fnode *next;
}Fnode;
void F_push(Fnode *h,char c)/*尾插*/
{
Fnode *p;
p=(Fnode*)malloc(sizeof(Fnode));
p->fh=c;
p->next=NULL;
if(c=='+'||c=='-')
p->yxj=1;
else if(c=='*'||c=='/')
p->yxj=2;
else if(c=='('||c==')')
p->yxj=0;
else
{ free(p); return;}
while(h->next!=NULL)
h=h->next;
p->next=h->next;
h->next=p;
}
char
(1)8
(2)2
这样分步显示每次计算的结果。就在原程序上改写在下面。
#include<stdio.h>
#include<malloc.h>
#include<string.h>
typedef struct Fnode/*符号单链表*/
{
int yxj;
char fh;
struct Fnode *next;
}Fnode;
void F_push(Fnode *h,char c)/*尾插*/
{
Fnode *p;
p=(Fnode*)malloc(sizeof(Fnode));
p->fh=c;
p->next=NULL;
if(c=='+'||c=='-')
p->yxj=1;
else if(c=='*'||c=='/')
p->yxj=2;
else if(c=='('||c==')')
p->yxj=0;
else
{ free(p); return;}
while(h->next!=NULL)
h=h->next;
p->next=h->next;
h->next=p;
}
char
#include<stdio.h>
#include<malloc.h>
#include<string.h>
typedef struct Fnode/*符号单链表*/
{
int yxj;
char fh;
struct Fnode *next;
}Fnode;
void F_push(Fnode *h,char c)/*尾插*/
{
Fnode *p;
p=(Fnode*)malloc(sizeof(Fnode));
p->fh=c;
p->next=NULL;
if(c=='+'||c=='-')
p->yxj=1;
else if(c=='*'||c=='/')
p->yxj=2;
else if(c=='('||c==')')
p->yxj=0;
else
{ free(p); return;}
while(h->next!=NULL)
h=h->next;
p->next=h->next;
h->next=p;
}
char F_pop(Fnode *h)/*尾删*/
{
char c;
while(h->next->next!=NULL)