微软计算器c语言代码大全,C语言写的仿WINDOWS 界面计算器源码

来源:

ryw12403的个人空间

作者:

若水

2008-05-07/17:59

case 26:   /*清除当前显示的值(Del键)*/

Resetbuf();

num1=0;

strcpy(txtscreen.caption,strbuf);

TextBox(txtscreen);

break;

case 27:   /*清除所有的值,包括存储的,已经运算了的(ESC键)*/

Resetbuf();

num1=num2=0;

ctnflag=FALSE;

operatoror=0;

runflag=FALSE;

errorflag=FALSE;

strcpy(txtscreen.caption,"0.");

TextBox(txtscreen);

break;

case 0:

Unload();

break;

}

if(errorflag==FALSE)

{  if(atof(txtscreen.caption)==0)

strcpy(txtscreen.caption,"0");

if(strchr(txtscreen.caption,'.')==NULL)

strcat(txtscreen.caption,".");

}

TextBox(txtscreen); /*显示txtscreen结构变量的值*/

}

void DoubleRun() /*四则运算*/

{  switch(operatoror)

{      case 13: num2+=num1;break;  /*加*/

case 14: num2-=num1;break; /*减*/

case 15: num2*=num1;break; /*乘*/

case 16: if(num1==0)     /*除*/

errorflag=TRUE;

else

num2/=num1;#p#分页标题#e#

break;

}

if(errorflag)

strcpy(txtscreen.caption,"Can't divide by zero!");

else

sprintf(txtscreen.caption,"%G",num2);

}

void SingleRun(int key) /*单运算*/

{  switch(key)

{  case 17:  /*求开方*/

if(num1<0)

errorflag=TRUE;

else

num1=sqrt(num1);

break;

case 18:  /*求百分比*/

num1/=100;

break;

case 19: /*求倒数*/

if(num1==0)

errorflag=TRUE;

else

num1=1/num1;

break;

}

if(errorflag==TRUE)

if(num1<0)

strcpy(txtscreen.caption,"Can't blower than zero!");

else

strcpy(txtscreen.caption,"Can't equal to zero!");

else

sprintf(txtscreen.caption,"%G",num1);

}

void StoreSet(int key)  /*记忆存储操作*/

{  switch(key)

{  case 21:   /*保存清除*/

store=0;

lblstore.caption[0]=0;

break;

case 22:  /*取出保存的值*/

num1=store;

sprintf(txtscreen.caption,"%G",store);#p#分页标题#e#

runflag=FALSE;

if(ctnflag==FALSE) operatoror=0;

break;

case 23:  /*保存当前数字*/

store=num1;

strcpy(lblstore.caption,"M");

break;

case 24:  /*保存值与当前数字相加*/

store+=num1;

strcpy(lblstore.caption,"M");

break;

}

Label(lblstore);

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值