求助啊!!!有错误,求助改正
#include"dos.h"#include"conio.h"
#include"string.h"
#include"stdio.h"
#define normbut_bor 0x80
#define presbut_but 0xb8
#define normnum_but 0x8e
#define presnum_but 0xb9
#define spebut_char 0x2c
#define win_color 0xf2
#define win_char 0xfb
struct s_button /*按键的结构体*/
{ int sx,sy,ex,ey;
char *head;
int press;
}button[17]; /*图表按键数*/
struct stack /*结构体栈*/
{ char s[20];
int tos,top;
}stack;
char tag;
{
if(stack.tos>0)
stack.s[--stack.tos]='\0';
}
draw_win() /*边框画线窗口*/
{
int i;
char far *t;
char *s="This is a simple calculator!"; /*顶端边框输出的字符*/
draw_border(30,0,79,24,win_color); /*边框的位置和颜色*/
i=(79-30-strlen(s))/2+30;
t=vid_mem+i*2;
for(;*s;)
{
*t++=*s++;
*t++=win_color; /*顶端字体颜色*/
}
}
draw_border(int sx,int sy,int ex,int ey,int attrib) /*边界线函数*/
{
char far *t,far *v;
int i;
t=vid_mem;
for(i=sx+1;i<ex;i++)
{
v=t+sy*160+i*2;
*v++=196; /*每一行上画线确定为直线*/
*v=attrib;
v=t+ey*160+i*2;
*v++=196; /*每一行下画线确定为直线*/
*v=attrib;
}
for(i=sy+1;i<ey;i++)
{ v=t+i*160+sx*2;
*v++=179; /*每一列左画线确定为直线*/
*v=attrib;
v=t+i*160+ex*2;
*v++=179; /*每一列由画线确定为直线*/
*v=attrib;
}
write_char(sx,sy,218,attrib);
write_char(ex,sy,191,attrib);
write_char(sx,ey,192,attrib);
write_char(ex,ey,217,attrib);
}
write_char(int x,int y,char ch,int attrib) /*字符输入函数*/
{ char far *v;
v=vid_mem;
v+=x*2+160*y;
*v++=ch;
*v=attrib;
}
active_button()/*图表按钮设定函数*/
{ int i;
make_button(0,32,9,38,11,"1");/*每个键对应的位置和数值*/
make_button(1,42,9,48,11,"2");
make_button(2,52,9,58,11,"3");
make_button(3,62,9,67,11,"+");
make_button(4,71,9,76,11,"-");
make_button(5,32,12,38,14,"4");
make_button(6,42,12,48,14,"5");
make_button(7,52,12,58,14,"6");
make_button(8,62,12,67,14,"*");
make_button(9,71,12,76,14,"/");/*“/”的位置*/
make_button(10,32,15,38,17,"7");
make_button(11,42,15,48,17,"8");
make_button(12,52,15,58,17,"9");
make_button(13,62,15,67,17,"=");
make_button(14,71,15,76,17,"<-");
make_button(15,32,18,38,20,"0");/*“0”的位置*/
make_button(16,71,18,76,20,"End");
for(i=0;i<17;i++)
{
draw_border(button[i].sx,button[i].sy,button[i].ex,button[i].ey,normbut_bor);
}
for(i=0;i<17;i++)
{
write_top(button[i].sx+1,button[i].sy+1,button[i].ex-1,button[i].head,normnum_but);
}
}
write_top(int x1,int y,int x2,char *s,int attrib)
{
char far *v,far *t;
int i;
v=vid_mem;
for(i=x1;i<=x2;i++)
{ t=v+y*160+i*2;
*t++=' ';
*t=attrib;
}
i=(x2-x1-strlen(s)+1)/2+x1;
t=v+160*y+i*2;
for(;*s;)
{ *t++=*s++;
*t++=attrib;
}
}
text_clo() /*文本光标*/
{ tx--; /*光标向左移*/
if(tx<32)tx++; /*backspace时X不能小于32*/
put_char(tx,ty,'');
}
put_string() /*计算机运算函数*/
{ float result;
tx=32;
switch(tag) /*根据运算符号计算*/
{
case '+': result=v1+v2;break; /*做加法*/
case '-':result=v1-v2;break; /*做减法*/
case'*':result=v1*v2;break; /*做乘法*/
case '/': result=v1/v2;break; /*做除法*/
default :result=v1; /*若不计算输出0*/
}
sprintf(stack.s,"%.3f",result); /*输出结果保留小数点后三位*/
while(stack.s[stack.top])
{ put_char(tx,ty,stack.s[stack.top++]);
tx++;
}
}
send1() /*向服务器发送请求*/
{ sscanf(stack.s,"%f",&v1); /*输入并储存在V1中*/
clear_stack(); /*清除栈*/
}
send2() /*向服务器发送信息*/
{ sscanf(stack.s,"%f",&v2);
clear_stack(); /*清除栈*/
}
select_but(int x,int y) /*选择按钮*/
{ int num;
if(y>2)
if(x<2)num=15;
else num=x+5*y;
draw_border(button[num].sx,button[num].sy,button[num].ex,button[num].ey,presbut_but);
write_top(button[num].sx+1,button[num].sy+1,button[num].ex-1,button[num].head,presnum_but);
}
write_top(button[num].sx+1,button[num].sy+1,button[num].ex-1,button[num].head,normnum_but);
}
else
{
draw_border(button[num].sx,button[num].sy,button[num].ex,button[num].ey,normbut_bor);
write_top(button[num].sx+1,button[num].sy+1,button[num].ex-1,button[num].head,spebut_char);
}
}
put_char(int x,int y,char ch) /*计算窗口的输入确定函数*/
{
char far *v;
v=vid_mem;
v+=x*2+y*160; /*光标的位置*/
*v++=ch; /*输入字符随光标的推进*/
*v=0xf0; /*输入数字的颜色*/
window_xy(x,y); /*光标在窗口坐标*/
}
calculator() /*计算器构成的函数*/
{
int a,b;
key_choice(); /*键选择函数*/
}
menu() /*左边窗口函数*/
{ char *j="This is a calculator!\nConductor Teacher:\nCheng YaHui\n\nStudent:Chen ChunLin\nNumber:0841330197\nSchool:ShaoYang College” "
char *s="Use Guide:\nInput the number from\n the keyborde"
draw_border(0,0,29,24,win_color); /*左边框的位置和颜色*/
write_top(1,2,28,"Introduction",0xf9);/*INTRODCTION的位置和颜色*/
write_text(2,5,j,0x79); /*输入字符的位置和颜色*/
write_text(2,17,s,0x79); /*输入字符的位置和颜色*/
}
main()
{
init_stack();
vid_mem=(char far *)0xb8000000;
if(!form_win())
{
printf("can't form the device,press any key to leave!...");/*如果不能显示见面窗口,按任意退出。*/
getch();
exit();
}
menu();
calculator();
}
main()
{
init_stack();
vid_mem=(char far *)0xb8000000;
if(!form_win())
{
printf("can't form the device,press any key to leave!...");/*如果不能显示见面窗口,按任意退出。*/
getch();
exit();
} menu();
calculator();
}