y(str2,""); /*设置str2为空串*/ while((v=specialkey())!=45) /*当压下Alt+x键结束程序,否则执行下面的循环*/ { while((v=specialkey())!=ENTER) /*当压下键不是回车时*/ { putimage(x,y,rar,XOR_PUT); /*显示光标图象*/ if(v==RIGHT) /*右移箭头时新位置计算*/ if(x>=x0+6*width) /*如果右移,移到尾,则移动到最左边字符位置*/ { x=x0; m=0; } else { x=x+width+width/2; m++; } /*否则,右移到下一个字符位置*/ if(v==LEFT) /*左移箭头时新位置计算*/ if(x<=x0) { x=x0+6*width; m=4; } /*如果移到头,再左移,则移动到最右边字符位置*/ else { x=x-width-width/2; m--; } /*否则,左移到前一个字符位置*/ if(v==UP) /*上移箭头时新位置计算*/ if(y<=y0) { y=y0+4*height+height/2; n=3; } /*如果移到头,再上移,则移动到最下边字符位置*/ else { y=y-height-height/2; n--; } /*否则,移到上边一个字符位置*/ if(v==DOWN) /*下移箭头时新位置计算*/ if(y>=7*height) { y=y0; n=0; } /*如果移到尾,再下移,则移动到最上边字符位置*/ else { y=y+height+height/2; n++; } /*否则,移到下边一个字符位置*/ putimage(x,y,rar,XOR_PUT); /*在新的位置显示光标箭头*/ } c=str1[n*5+m]; /*将字符保存到变量c中*/ if(isdigit(c)||c=='.') /*判断是否是数字或小数点*/ { if(flag==-1) /*如果标志为-1,表明为负数*/ { strcpy(str2,"-"); /*将负号连接到字符串中*/ flag=1; } /*将标志值恢复为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=='+') { num1=atof(str2); /*将第一个操作数转换为浮点数*/ strcpy(str2,""); /*将str2清空*/ act=1; /*做计算加法标志值*/ setfillstyle(SOLID_FILL,color+3); bar(2*width+width/2,height/2,15*width/2,3*height/2); outtextxy(5*width,height,"0."); /*显示字符串*/ } if(c=='-') { if(strcmp(str2,"")==0) /*如果str2为空,说明是负号,而不是减号*/ flag=-1; /*设置负数标志*/ else { num1=atof(str2); /*将第二个操作数转换为浮点数*/ strcpy(str2,""); /*将str2清空*/ act=2; /*做计算减法标志值*/ setfillstyle(SOLID_FILL,color+3); bar(2*width+width/2,height/2,15*width/2,3*height/2); /*画矩形*/ outtextxy(5*width,height,"0."); /*显示字符串*/ } } if(c=='*') { num1=atof(str2); /*将第二个操作数转换为浮点数*/ strcpy(str2,""); /*将str2清空*/ act=3; /*做计算乘法标志值*/ setfillstyle(SOLID_FILL,color+3); bar(2*width+width/2,height/2,15*width/2,3*height/2); outtextxy(5*width,height,"0."); /*显示字符串*/ } if(c=='/') { num1=atof(str2); /*将第二个操作数转换为浮点数*/ strcpy(str2,""); /*将str2清空*/ act=4; /*做计算除法标志值*/ setfillstyle(SOLID_FILL,color+3); bar(2*width+width/2,height/2,15*width/2,3*height/2); outtextxy(5*width,height,"0."); /*显示字符串*/ } if(c=='^') { num1=atof(str2); /*将第二个操作数转换为浮点数*/ strcpy(str2,""); /*将str2清空*/ act=5; /*做计算乘方标志值*/ setfillstyle(SOLID_FILL,color+3); /*设置用淡绿色实体填充*/ bar(2*width+width/2,height/2,15*width/2,3*height/2); /*画矩形*/ outtextxy(5*width,height,"0."); /*显示字符串*/ } if(c=='%') { num1=atof(str2); /*将第二个操作数转换为浮点数*/ strcpy(str2,""); /*将str2清空*/ act=6; /*做计算 |