c语言编写计算器.doc

上传人:啊飒飒 文档编号:11368442 上传时间:2021-07-30 格式:DOC 页数:11 大小:24.50KB
返回 下载 相关 举报
c语言编写计算器.doc_第1页
第1页 / 共11页
c语言编写计算器.doc_第2页
第2页 / 共11页
c语言编写计算器.doc_第3页
第3页 / 共11页
c语言编写计算器.doc_第4页
第4页 / 共11页
c语言编写计算器.doc_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《c语言编写计算器.doc》由会员分享,可在线阅读,更多相关《c语言编写计算器.doc(11页珍藏版)》请在三一文库上搜索。

1、#define MAX 80#define MAX1 40#define MAX2 40#define NULL 0#include #include typedef structdouble A MAX1 ;int top1;shuju;typedef structchar B MAX2 ;int top2;yunsuanfu;void chushihua1(shuju *p)p-top1 = 0;void chushihua2(yunsuanfu *p)p-top2 = 0;int charu1(shuju *p,double x)if(p-top1 = (MAX1 - 1) printf

2、(you are wrong1n);return 0; elsep-A p-top1 = x;p-top1+;return 1;int charu2(yunsuanfu *p,char x)if(p-top2 = (MAX2 - 1) printf(you are wrong2n);return 0; elsep-B p-top2 = x;p-top2+;return 1;int chuzhuan1(shuju *p,double *x)if(p-top1 top1-;*x=p-A p-top1 ;return 1;int chuzhuan2(yunsuanfu *p,char *x)if(p

3、-top2 top2-;*x=p-B p-top2 ;return 1;int op(char f,char b)if(f = ( & b = ) | (f = 0 & b = 0)return 2; else if(b = * | b = /) & (f = + | f = -)|(b = ( & f != ) | (f = ( | f = 0) & (b = + | b = / | b = - | b = *)return -1; else if(b = 0 & f != () | (b = ) & f != 0) | b = f | (f = * | f = / | f = ) & (b

4、 = + | b = / | b = - | b = *)return 1;elseprintf(tttyou are wrongn);return 0;double zhuanhuan(int x,int y,char a)int i, j=0, k;double n=0;for(i=x; iy; i+) if(a i != .)n = n*10+a i -0;else j=i; if(j = 0)return n; elsefor(k=0; k = 0 & k j = 9 )j+;n=zhuanhuan(i,j,k);switch(B)case 1: n=sin(n);break;case

5、 2: n=cos(n);break;case 3: n=tan(n);break;case 4: n=log10(n);break;case 5: n=log(n);charu1(&a, n);b1 = 0;while(b1 = 0)bi = op(ch, kj );if(bi = 0)jieshu();while(bi = 1)m = f1(&a, &b);chuzhuan2(&b, &ch);bi = op(ch, k j );charu2(&b, ch);if(bi = -1)dof2(j, &b,k);j+;while(kj = ();j-; else if(bi = 2)if(ch = ()if(k j = )j+;chuzhuan2(&b, &ch);chuzhuan2(&b, &ch);charu2(&b, ch);continue; else chuzhuan1(&a, &m);b1 = 1;if(k j = 0)break;elsech = k j ;j+;i = j;B = 0; printf(ttt);textcolor(30);cprintf(The answer is %f,m);printf(n);jieshu();

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1