三九宝宝网宝宝教育教学论文

数据结构后缀法表达式求值C语言编写

02月23日 编辑 39baobao.com

[高手速度来跪求数据结构用C语言编写 1创建链表 L要用到以下函数]以前的实验题。 #define OK 1 #define NULL 0 #define ERROR 2 #define ElemType int #include "iostream.h" #include "stdio.h" #include "stdlib.h" typedef struct LNode { in...+阅读

#includeusing namespace std; #include#include#define add 43 #define subs 45 #define mult 42 #define div 47 #define MAXSIZE 100 typedef struct { int stkdata[MAXSIZE]; int top; } STKzone; typedef STKzone *STK; typedef enum {True=1,False=0} boo; typedef enum {ok,error} status; STKzone expSTKzone; STK expSTK; STK initSTK(STKzone *stack_zone) { stack_zone->top=-1; return stack_zone; } status push(int*term,STK pstk) { if(pstk->top==MAXSIZE-1) return error; pstk->stkdata[++pstk->top]=*term; return ok; }/*push*/ bool emptySTK(STK pstk) { return(pstk->top==-1); } status pop(int *pdata,STK pstk) { if(emptySTK(pstk)) return error; else { *pdata=pstk->stkdata[pstk->top]; (pstk->top)--; return ok; } } void synerror() { printf("\n 表达式语法错误!\n"); exit(0); } int eval(int a1,int a2,char tag) { switch(tag) { case add: return(a1+a2); case subs: return(a1-a2); case mult: return(a1*a2); case div: return(a1/a2); } } int main() { char c; int opd1,opd2,temp,c1; expSTK=initSTK(&expSTKzone); opd1 = 1; opd2 = 2; push(&opd1,expSTK); push(&opd2,expSTK); printf("\n后缀表达式:"); while((c=getchar())!='/n') { if(c==' ')continue; if((c>47)&(c

以下为关联文档:

大神们求解:用c语言的for循环结构编写此文本图像#include<stdio.h> int main() { int i,j,s; for(j=65;j<69;j++) { for(i=65;i<j;i++) printf("%c",i); printf("\n"); } for(s=68;s>=65;s--) { for(i=65;i<s;i++) printf("%c",i...

C语言数据结构与算法分析C语言描述Position不是一个类型,起码C语言中,我写那么多年代码没见过这个类型 。你该把整段代码贴上来。我猜你看的那段代码是伪代码,Position是自定义类型。若Position是类名,那么Positi...

用汇编语言编写这个表达式xyzx调试的时候能够将输入的x,y,z经过计算输出?你的意思是说,这个程序能够实现输入x,y,z后输出结果吧? 如果有输入输出就要涉及到十六进制和十进制之间的转换,一下代码没考虑这些,如...

关于用C语言编写DES算法中的读入文件数据问题用fgets函数可以读取文件中某行的数据,某列数据就必须一个一个读入每行的第几个字符,再存入到一个字符串当中。 例程: #include #include void main() { char a[100],b[100],c[...

用C语言中的结构体编写程序#include<stdio.h> struct book{ char name[10]; int num; }book; int main() { int i; struct book b[20]; for(i=0;i<20;i++)//依次读入20个书名 {scanf("%s",&b[i].name);...

用c语言结构体编写//很明显这是结构体定义 struct studentNode{ char name[30]; char sno[30]; }; //比较字符数组的函数,对于结构体中的字符数组,直接用串比较可能会错误处理一些特殊字符。 bo...

数据结构里括号匹配的程序用C语言编写的#includeusing namespace std; #define maxsize 100 struct sStack { char sign[maxsize]; int top; }; int InitsStack(sStack &SS) { SS.top=-1; return 1; } int IsEmpty...

C语言数据结构中的几种内部排序法求解!高手速度来指导我。以前的实验题。#define OK 1#define NULL 0#define ERROR 2#define ElemType int#include "iostream.h" #include "stdio.h"#include "stdlib.h" typedef struct LNode { int data...

数据结构中用c语言怎么编写用单链表将26个字母排序的程序#include #include //申明链表 typedef struct node { char num; struct node *next; }list; void Bubble_sort(list *L);//链表的冒泡排序 void Dis_list(list *L);//遍历单...

推荐阅读
图文推荐