資源簡介
使用鍵盤輸入表達式,計算表達式的值并輸出;將表達式轉化成后綴表達式輸出,利用后綴表達式求表達式的值并輸出。在此過程中進一步實現負數的識別,符號的多種形式的判斷。
代碼片段和文件信息
#include
#include
#include
#define?maxsize?10000
typedef?struct?linkstacknum
{//運算數棧定義
double?num;
struct?linkstacknum?*next;
}linkstacknum*plinkstacknum;
typedef?struct?linkstackoper
{//運算符棧定義
char?oper;
struct?linkstackoper?*link;
}linkstackoper*plinkstackoper;
plinkstacknum?OPND;
plinkstackoper?OPTR;
plinkstacknum?innumstack(plinkstacknum?p)
{//生成數棧
p=(plinkstacknum)malloc(sizeof(linkstacknum));
if(p!=NULL)
{
p->next=NULL;
}
else
{
printf(“out?of?space!\n“);
}
return?p;
}
plinkstackoper?inoperstack(plinkstackoper?q)
{//生成數符棧
q=(plinkstackoper)malloc(sizeof(linkstackoper));
if(q!=NULL)
{
q->link=NULL;
}
else
{
printf(“out?of?space!\n“);
}
return?q;
}
plinkstacknum?pushnum(plinks
- 上一篇:Symbol 掃描軟件
- 下一篇:基于HanLP的漢語詞性標注表
評論
共有 條評論