如何做一个计算器的C语言程序,一个纯C实现的图形化计算器

这篇博客分享了一个用C语言编写的图形化计算器程序,涵盖了加减乘除、平方根、内存操作等基本功能。代码展示了如何利用图形库和鼠标事件处理用户交互,并提供了完整的源代码供读者参考学习。
摘要由CSDN通过智能技术生成

下面是编程之家 jb51.cc 通过网络收集整理的代码片段。

编程之家小编现在分享给大家,也给大家做个参考。

#include"graphics.h"

#include"dos.h"

#include"stdio.h"

#include"math.h"

union REGS i,o;

char *text[]={ "7","8","9","*","4","5","6","/","1","2","3","+","0","00",".","-","M","M+","M-","+/-","MR","MC","x^2","sr","OFF","AC","CE","="};

int k=0,pass,op,prop,newnum=1,bt,memo=1,d=0,sq;

long double num=0,accum,m;

void normalbutton(int,int,char**);

void main()

{

int gd=DETECT,gm,x1,x2,y1,y2,i,j,maxx,maxy,x,y,button;

char *text1[]={""","T","o"," ","K","n","w","a","b","u","t","m","e","l","g",":"};

char *text2[]={"w","c","i","s","k","d","p","h"};

initgraph(&gd,&gm,"");

if(initmouse()==0)

{

closegraph();

restorecrtmode();

printf("

Mouse driver not loded");

exit(1);

}

showmouseptr();

// x=y=50;

movemouseptr(&x,&y);

setbkcolor(11);

setcolor(1);

rectangle(198,140,417,163);

rectangle(199,141,418,164);

rectangle(197,139,416,162);

rectangle(185,130,430,450);

rectangle(184,129,431,451);

rectangle(182,127,433,454);

rectangle(181,126,434,453);

//setfillstyle(SOLID_FILL,3);

//bar(200,142,415,161);

outtextxy(200,50,"A Calculator in C");

outtextxy(200,100,"Press OFF button to exit....");

y1=140;

y2=160;

for(j=0;j<7;j++)

{

x1=200;

x2=235;

y1+=40;

y2

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值