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);
}
评论 {{userinfo.comments}}
{{child.content}}
{{question.question}}
提交