第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

打???的地方看得不是很懂,求高人指點(diǎn)一下哈

打???的地方看得不是很懂,求高人指點(diǎn)一下哈

C
牧羊人nacy 2023-04-01 14:10:16
#include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#define MAX_SIZE 256enum BOOL{FALSE,TRUE};typedef struct tagOPERATE{double Operand;char Operator;}OPERATE,*LPOPERATE;int IsDigit(char);int isp(char ch); int icp(char ch);int Locate(char ch);void PostSrc(char*src,LPOPERATE lpOperator);int getOperand(char *s,int *len,double *oprd);double Calculate(LPOPERATE lpOperator);static char Operator[]="#(+-*/^"; //?????static int InPriority[]={0,1,3,3,5,5,7}; //????static int OutPriority[]={0,10,2,2,4,4,6}; //?????int Locate(char ch)  {int i=0;for(i=0;Operator[i]!='\0';i++)if(Operator[i]==ch)return i;return -1;}int isp(char ch)  {if('A'<=ch&&'Z'>=ch)return 9;elsereturn InPriority[Locate(ch)];}int icp(char ch)  {if('A'<=ch&&'Z'>=ch)return 8;elsereturn OutPriority[Locate(ch)];}void PostSrc(char*src,LPOPERATE lpOperator){char *p=src,y;LPOPERATE lpOptr=lpOperator;char stack[MAX_SIZE];int top=-1; double Operand;int offset=0;stack[++top]='#';while('\0'!=*p){if(IsDigit(*p)){getOperand(p,&offset,&Operand);p+=offset;lpOptr->Operand=Operand;lpOptr->Operator=0;lpOptr++;}elseif(')'==*p){for(y=stack[top--];y!='(';y=stack[top--])(lpOptr++)->Operator=y;p++;}else{for(y=stack[top--];isp(y)>icp(*p);y=stack[top--]) //?????(lpOptr++)->Operator=y;stack[++top]=y;stack[++top]=*p++;}}while(top!=-1)(lpOptr++)->Operator=stack[top--];  }int IsDigit(char ch){if(('0'<=ch&&'9'>=ch)||'.'==ch)return TRUE;return FALSE;}int getOperand(char *s,int *len,double *oprd){char *p = s,ch = *s++;double z = 0,x = 0;int bits = 0;int point = FALSE;while( IsDigit(ch) == TRUE){if (ch == '.'){if (point == TRUE) return FALSE;point = TRUE;}else {if (point == TRUE){x *= 10;x += ch - '0';bits++;}else {z *= 10;z += ch - '0';}}ch = *s++;}while(bits-- > 0) x /= 10;z += x;*oprd = z;*len = s - p - 1;return TRUE;}
查看完整描述

2 回答

?
搖曳的薔薇

TA貢獻(xiàn)1793條經(jīng)驗(yàn) 獲得超6個(gè)贊

這個(gè)應(yīng)該是頭文件,但是公共函數(shù)應(yīng)該加上inline優(yōu)化一下。
enum 枚舉變量 BOOL
結(jié)構(gòu),包含一個(gè)double類(lèi)型和char類(lèi)型
int IsDigit(char); //判斷是否是數(shù)字(0-9)
int isp(char ch); //判斷是否是字符(A-Z) 返回相應(yīng)的InPriority數(shù)組中值
int icp(char ch); //判斷是否是字符(A-Z) 返回相應(yīng)的OutPriority數(shù)組中值
int Locate(char ch);//判斷是否運(yùn)算符(+,-,*,/,^) 

猜想一下,這個(gè)估計(jì)是用來(lái)做詞法分析的,分析字符串的運(yùn)算表達(dá)式。
做編譯器?

查看完整回答
反對(duì) 回復(fù) 2023-04-05
?
胡說(shuō)叔叔

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超8個(gè)贊

static char Operator[]="#(+-*/^"; //?????
運(yùn)算/操作符。Operator[0]="#" 是 棧操作,push,pop. Operator[1]="(" 是 括號(hào),進(jìn)入一層。Operator[2]="+",Operator[3]="-",
Operator[4]="*",Operator[5]="/",是 加減乘除,Operator[6]="^" 是冪 運(yùn)算.
static int InPriority[]={0,1,3,3,5,5,7}; //????
進(jìn)入/輸入時(shí)的優(yōu)先級(jí)
static int OutPriority[]={0,10,2,2,4,4,6}; //?????
退出/輸出時(shí)的優(yōu)先級(jí)

for(y=stack[top--];isp(y)>icp(*p);y=stack[top--]) //?????
從棧頂起,往下查一個(gè)一個(gè)字符,按優(yōu)先級(jí)isp(y)>icp(*p)判斷循環(huán)終了。

查看完整回答
反對(duì) 回復(fù) 2023-04-05
  • 2 回答
  • 0 關(guān)注
  • 169 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)