c语言程序设计电子版本Word文档格式.docx

上传人:b****1 文档编号:13374509 上传时间:2022-10-10 格式:DOCX 页数:12 大小:18.56KB
下载 相关 举报
c语言程序设计电子版本Word文档格式.docx_第1页
第1页 / 共12页
c语言程序设计电子版本Word文档格式.docx_第2页
第2页 / 共12页
c语言程序设计电子版本Word文档格式.docx_第3页
第3页 / 共12页
c语言程序设计电子版本Word文档格式.docx_第4页
第4页 / 共12页
c语言程序设计电子版本Word文档格式.docx_第5页
第5页 / 共12页
点击查看更多>>
下载资源
资源描述

c语言程序设计电子版本Word文档格式.docx

《c语言程序设计电子版本Word文档格式.docx》由会员分享,可在线阅读,更多相关《c语言程序设计电子版本Word文档格式.docx(12页珍藏版)》请在冰豆网上搜索。

c语言程序设计电子版本Word文档格式.docx

2.编写计算器的源程序代码;

3.上机调试;

4.答辩;

5.书写实习报告。

四、课程设计所用设备:

每人一台计算机。

五、课程设计系统组成及模块功能:

(1)主函数模块

(2)设置系统进入图形模块

(3)初始化图形系统模块

(4)计算器计算函数模块

(5)窗口函数模块

(6)设计鼠标图形函数模块

(7)获取特殊键函数模块

六、软件环境:

Visualc++6.0

七、课程设计要求:

在计算机上操作,通过Visualc++6.0,设计出“计算器”程序。

八、应提交的材料:

实习报告一份,内容包含“计算器”程序代码。

设计报告:

程序代码:

#include<

dos.h>

math.h>

conio.h>

stdio.h>

stdlib.h>

stdarg.h>

graphics.h>

string.h>

ctype.h>

#defineUP0x48

#defineDOWN0x50

#defineLEFT0x4b

#defineRIGHT0x4d

#defineENTER0x0d

void*rar;

structpalettetypepalette;

intGraphDriver;

intGraphMode;

intErrorCode;

intMaxColors;

intMaxX,MaxY;

doubleAspectRatio;

voiddrawboder(void);

voidinitialize(void);

voidcomputer(void);

voidchangetextstyle(intfont,intdirection,intcharsize);

voidmwindow(char*header);

intspecialkey(void);

intarrow();

intmain()

{

initialize();

computer();

closegraph();

return(0);

}

voidinitialize(void)

intxasp,yasp;

GraphDriver=DETECT;

initgraph(&

GraphDriver,&

GraphMode,"

"

);

ErrorCode=graphresult();

if(ErrorCode!

=grOk)

{

printf("

GraphicsSystemError:

%s\n"

grapherrormsg(ErrorCode));

exit

(1);

}

getpalette(&

palette);

MaxColors=getmaxcolor()+1;

MaxX=getmaxx();

MaxY=getmaxy();

getaspectratio(&

xasp,&

yasp);

AspectRatio=(double)xasp/(double)yasp;

voidcomputer(void)

structviewporttypevp;

intcolor,height,width;

intx,y,x0,y0,i,j,v,m,n,act,flag=1;

floatnum1=0,num2=0,result;

charcnum[5],str2[20]={"

},c,temp[20]={"

};

charstr1[]="

1230.456+-789*/Qc=^%"

;

mwindow("

Calculator"

color=7;

getviewsettings(&

vp);

width=(vp.right+1)/10;

height=(vp.bottom-10)/10;

x=width/2;

y=height/2;

setfillstyle(SOLID_FILL,color+3);

bar(x+width*2,y,x+7*width,y+height);

setcolor(color+3);

rectangle(x+width*2,y,x+7*width,y+height);

setcolor(RED);

outtextxy(x+3*width,y+height/2,"

0."

);

x=2*width-width/2;

y=2*height+height/2;

for(j=0;

j<

4;

++j)

for(i=0;

i<

5;

++i)

setfillstyle(SOLID_FILL,color);

bar(x,y,x+width,y+height);

rectangle(x,y,x+width,y+height);

sprintf(str2,"

%c"

str1[j*5+i]);

outtextxy(x+(width/2),y+height/2,str2);

x=x+width+(width/2);

y+=(height/2)*3;

x0=2*width;

y0=3*height;

x=x0;

y=y0;

gotoxy(x,y);

arrow();

putimage(x,y,rar,XOR_PUT);

m=0;

n=0;

strcpy(str2,"

while((v=specialkey())!

=45)

=ENTER)

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;

x=x-width-width/2;

m--;

if(v==UP)

if(y<

=y0)

y=y0+4*height+height/2;

n=3;

y=y-height-height/2;

n--;

if(v==DOWN)

if(y>

=7*height)

y=y0;

y=y+height+height/2;

n++;

c=str1[n*5+m];

if(isdigit(c)||c=='

.'

if(flag==-1)

-"

flag=1;

sprintf(temp,"

c);

strcat(str2,temp);

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);

act=1;

outtextxy(5*width,height,"

-'

if(strcmp(str2,"

)==0)

flag=-1;

act=2;

*'

act=3;

/'

act=4;

^'

act=5;

%'

act=6;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 数学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1