C语言表达式求值代码

C语言表达式求值代码


2024年5月4日发(作者:)

表达式求值,可直接复制到VC中运行。

#include

#include

#include

#include

static int gv_a;

typedef struct list //创建队列元素型

{

char str[10];

struct list*pNext;

}LIST;

typedef struct queue

{

LIST *front;

LIST *rear;

}QUEUE;

//创建队列表型

typedef struct oprstack

{

char opr[100];

int a;

}OPRSTACK;

typedef struct valstack

{

float val[30];

int a;

}VALSTACK;

//创建运算符栈型

//创建运算栈型

typedef struct element //创建表达式栈元素型

{

char c;

struct element *pNext;

}ENT;

typedef struct stack //创建表达式栈 型

{

ENT *pTop;

ENT *bottom;

}STACK;

bool calc(char *str,float *result);

float evaluationofexpression(char *str);

int main(void)

{

char str[50];

float result;

printf("请输入要计算的表达式:");

scanf("%s",str);

result = evaluationofexpression(str);

if (gv_a)

return 0;

printf("结果:%f",result);

printf("n");

return 0;

}

/*=======================================================*/

/*==================不带括号表达式求值===================*/

/*=======================================================*/

void insert_char(char *p,char ent,int site)

{

int i=0,j;

while (p[i]!='0')

++i;

if(site>i)

{

p[i] = ent;

p[i+1] = '0';

return;

}

for (j=i;j>=site;--j)

{

p[j+1] = p[j];

}

p[site] = ent;

}

//向字符串中插入一个元素


发布者:admin,转转请注明出处:http://www.yc00.com/web/1714816200a2521525.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信