幫我做C語言計算器框架及流程已給出

2021-03-05 09:21:37 字數 5358 閱讀 2308

1樓:匿名使用者

#include

struct s_node

; typedef struct s_node s_list;

typedef s_list *link;

link operator=null;

link operand=null;

link push(link stack,int value)

newnode->data=value;

newnode->next=stack;

stack=newnode;

return stack;

} link pop(link stack,int *value)

else

*value=-1;

} int empty(link stack)

int is_operator(char operator) }

int priority(char operator) }

int two_result(int operator,int operand1,int operand2) }

void main()

operator=push(operator,expression[position]);

} else

operand=push(operand,expression[position]-48);

position++;

} while(!empty(operator))

printf("the expression [%s] result is '%d' ",expression,evaluate);

getch();}

2樓:匿名使用者

#include /*dos介面函式*/

#include /*數學函式的定義*/

#include /*螢幕操作函式*/

#include /*i/o函式*/

#include /*庫函式*/

#include /*變數長度參數列*/

#include /*圖形函式*/

#include /*字串函式*/

#include /*字元操作函式*/

#define up 0x48 /*游標上移鍵*/

#define down 0x50 /*游標下移鍵*/

#define left 0x4b /*游標左移鍵*/

#define right 0x4d /*游標右移鍵*/

#define enter 0x0d /*回車鍵*/

void *rar; /*全域性變數,儲存游標圖象*/

struct palettetype palette; /*使用調色盤資訊*/

int graphdriver; /* 圖形裝置驅動*/

int graphmode; /* 圖形模式值*/

int errorcode; /* 錯誤***/

int maxcolors; /* 可用顏色的最大數值*/

int maxx, maxy; /* 螢幕的最大解析度*/

double aspectratio; /* 螢幕的畫素比*/

void drawboder(void); /*畫邊框函式*/

void initialize(void); /*初始化函式*/

void ***puter(void); /*計算器計算函式*/

void changetextstyle(int font, int direction, int charsize); /*改變文字樣式函式*/

void mwindow(char *header); /*視窗函式*/

int specialkey(void) ; /*獲取特殊鍵函式*/

int arrow(); /*設定箭頭游標函式*/

/*主函式*/

int main()

/* 設定系統進入圖形模式 */

void initialize(void)

getpalette( &palette ); /* 讀面板資訊*/

maxcolors = getmaxcolor() + 1; /* 讀取顏色的最大值*/

maxx = getmaxx(); /* 讀螢幕尺寸 */

maxy = getmaxy(); /* 讀螢幕尺寸 */

拷貝縱橫比到變數中*/

aspectratio = (double)xasp/(double)yasp;/* 計算縱橫比值*/

}/*計算器函式*/

void ***puter(void)

,c,temp[20]=;

char str1="1230.456+-789*/qc=^%";/* 定義字串在按鈕圖形上顯示的符號 */

mwindow( "calculator" ); /* 顯示主視窗 */

color = 7; /*設定灰顏色值*/

讀取當前視窗的大小*/

width=(vp.right+1)/10; /* 設定按鈕寬度 */

height=(vp.bottom-10)/10 ; /*設定按鈕高度 */

x = width /2; /*設定x的座標值*/

y = height/2; /*設定y的座標值*/

setfillstyle(solid_fill, color+3);

bar( x+width*2, y, x+7*width, y+height );

/*畫一個二維矩形條顯示運算數和結果*/

setcolor( color+3 ); /*設定淡綠顏色邊框線*/

rectangle( x+width*2, y, x+7*width, y+height );

/*畫一個矩形邊框線*/

setcolor(red); /*設定顏色為紅色*/

outtextxy(x+3*width,y+height/2,"0."); /*輸出字串"0."*/

x =2*width-width/2; /*設定x的座標值*/

y =2*height+height/2; /*設定y的座標值*/

for( j=0 ; j<4 ; ++j ) /*畫按鈕*/

y +=(height/2)*3; /* 移動行座標*/

x =2*width-width/2; /*復位列座標*/

}x0=2*width;

y0=3*height;

x=x0;

y=y0;

gotoxy(x,y); /*移動游標到x,y位置*/

arrow(); /*顯示游標*/

putimage(x,y,rar,xor_put);

m=0;

n=0;

strcpy(str2,""); /*設定str2為空串*/

while((v=specialkey())!=45) /*當壓下alt+x鍵結束程式,否則執行下面的迴圈*/

else

/*否則,右移到下一個字元位置*/

if(v==left) /*左移箭頭時新位置計算*/

if(x<=x0)

/*如果移到頭,再左移,則移動到最右邊字元位置*/

else

/*否則,左移到前一個字元位置*/

if(v==up) /*上移箭頭時新位置計算*/

if(y<=y0)

/*如果移到頭,再上移,則移動到最下邊字元位置*/

else

/*否則,移到上邊一個字元位置*/

if(v==down) /*下移箭頭時新位置計算*/

if(y>=7*height)

/*如果移到尾,再下移,則移動到最上邊字元位置*/

else

/*否則,移到下邊一個字元位置*/

putimage(x,y,rar,xor_put); /*在新的位置顯示游標箭頭*/

}c=str1[n*5+m]; /*將字元儲存到變數c中*/

if(isdigit(c)||c=='.') /*判斷是否是數字或小數點*/

/*將標誌值恢復為1*/

sprintf(temp,"%c",c); /*將字元儲存到字串變數temp中*/

strcat(str2,temp); /*將temp中的字串連線到str2中*/

setfillstyle(solid_fill,color+3);

bar(2*width+width/2,height/2,15*width/2,3*height/2);

outtextxy(5*width,height,str2); /*顯示字串*/

}if(c=='+')

if(c=='-')

}if(c=='*')

if(c=='/')

if(c=='^')

if(c=='%')

if(c=='=')

setfillstyle(solid_fill,color+3); /*設定用淡綠色實體填充*/

bar(2*width+width/2,height/2,15*width/2,3*height/2); /*覆蓋結果區*/

sprintf(temp,"%f",result); /*將結果儲存到temp中*/

outtextxy(5*width,height,temp); /*顯示結果*/

}if(c=='c')

if(c=='q')exit(0); /*如果選擇了q回車,結束計算程式*/

}putimage(x,y,rar,xor_put); /*在退出之前消去游標箭頭*/

return; /*返回*/

}/*視窗函式*/

void mwindow( char *header )

void drawboder(void) /*畫邊框*/

/*設計滑鼠圖形函式*/

int arrow()

; /*定義多邊形座標*/

setfillstyle(solid_fill,2); /*設定填充模式*/

fillpoly(8,raw); /*畫出一游標箭頭*/

size=imagesize(4,4,16,16); /*測試圖象大小*/

rar=malloc(size); /*分配記憶體區域*/

getimage(4,4,16,16,rar); /*存放游標箭頭圖象*/

putimage(4,4,rar,xor_put); /*消去游標箭頭圖象*/

return 0;

}/*按鍵函式*/

int specialkey(void)

casio計算器螢幕上出現m及d如何消掉

m 是memory,意思是來 儲存著一個數字,自和普通計算器一樣,把0存一下,可能能清除,試試吧。d是角度的意思degree,角度弧度斜率必須選一個,角度是最常用的,最好不要消滅,非要消滅的話可以買一把錘子試試。casio的計算器怎麼去掉上面的m和sd?各種型號的具體操作可能不盡相同,但大致差不多。...

應用51微控制器語言編寫簡易計算器程式實驗目的在51實驗小系統硬體基礎上,在keil開發環境

在51實驗小系統硬體基礎上,首先得有一個51實驗小系統硬體。判斷好矩陣鍵盤就好了,思路並不難啊 怎樣用51微控制器做計算器啊?1 首先第一步就是要進行查詢元器件並放入到原理圖中,如下圖所示。2 接著就是要進行原理圖連線根據網路標籤的方式即可。3 然後就是要進行編寫程式,程式源 include inc...

如何用c 寫簡單的計算器程式,如何用c 寫一個簡單的計算器程式

include include include using namespace std void main cout number2 cin rightparstr leftparint atoi leftparstr.c str rightparint atoi rightparstr.c str...