C语言程序设计论文

上传人:d**** 文档编号:117198851 上传时间:2022-07-08 格式:DOCX 页数:16 大小:17.07KB
返回 下载 相关 举报
C语言程序设计论文_第1页
第1页 / 共16页
C语言程序设计论文_第2页
第2页 / 共16页
C语言程序设计论文_第3页
第3页 / 共16页
点击查看更多>>
资源描述
C 语言程序设计论文学校:天津电子信息职业技术学院系别:电子技术系专业:通信技术班级:通信 S13-26学号:89757姓名:王磊C 语言课程设计报告一、设计题目:计算器二、设计目标:进一步加深、巩固学生所学专业课程C语言的基本理论知识,理论 联系实际,进一步培养学生综合分析问题和解决问题的能力。掌握运用C语言独立地 编写、调试应用程序和进行其它相关设计的技能,充分发挥广大同学的潜力,使他们 通过本次课程设计而得到全面的锻炼。三、设计内容:1.设计系统的功能框图、流程图;2.编写计算器的源程序代码;3.上机调试;4.答辩; 5.书写实习报告。四、课程设计所用设备:每人一台计算机。五、课程设计系统组成及模块功能:1)主函数模块2)设置系统进入图形模块3)初始化图形系统模块4)计算器计算函数模块5)窗口函数模块6)设计鼠标图形函数模块7)获取特殊键函数模块六、软件环境: Visual c+6.0七、课程设计要求:在计算机上操作,通过Visual C+6.0,设计出“计算器”程序。八、应提交的材料:实习报告一份,内容包含“计算器”程序代码。设计报告:程序代码: #inClude #inClude #inClude #inClude #inClude #inClude #include #include #include #define UP 0x48 #define DOWN 0x50 #define LEFT 0x4b #define RIGHT 0x4d#define ENTER 0x0d void *rar;struct palettetype palette; int GraphDriver;int GraphMode;int ErrorCode;int MaxColors;int MaxX, MaxY;double AspectRatio;void drawboder(void);void initialize(void);void computer(void);void changetextstyle(int font, int direction, int charsize);void mwindow(char *header);int specialkey(void) ;int arrow();int main()initialize();computer();closegraph();return(0);void initialize(void)int xasp, yasp;GraphDriver = DETECT;initgraph( &GraphDriver, &GraphMode, );ErrorCode = graphresult();if( ErrorCode != grOk )printf(Graphics System Error: %sn, grapherrormsg( ErrorCode ) );exit( 1 );getpalette( &palette );MaxColors = getmaxcolor() + 1;MaxX = getmaxx();MaxY = getmaxy();getaspectratio( &xasp, &yasp );AspectRatio = (double)xasp/(double)yasp;void computer(void)struct viewporttype vp;int color, height, width;int x, y,x0,y0, i, j,v,m,n,act,flag=1;float num1=0,num2=0,result;char cnum5,str220=,c,temp20=;char strl=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 ; j4 ; +j )for( i=0 ; i=x0+6*width)x=x0;m=0;elsex=x+width+width/2;m+;if(v=LEFT)if(x=x0)x=x0+6*width;m=4;elsex=x-width-width/2;m-;if(v=UP)if(y=7*height)y=y0;n=0;elsey=y+height+height/2;n+;putimage(x,y,rar,XOR_PUT);c=str1n*5+m;if(isdigit(c)|c=.)if(flag=-1)strcpy(str2,-);flag=1;sprintf(temp,%c,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);strcpy(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)flag=-1;else num1=atof(str2); strcpy(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,);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,);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=A)num1=atof(str2); strcpy(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,); act=6;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=)num2=atof(str2);switch(act)case 1:result=num1+num2;break;case 2:result=num1-num2;break;case 3:result=num1*num2;break;case 4:result=num1/num2;break;case 5:result=pow(num1,num2);break;case 6:result=fmod(num1,num2);break;setfillstyle(SOLID_FILL,color+3);bar(2*width+width/2,height/2,15*width/2,3*height/2);sprintf(temp,%f,result);outtextxy(5*width,height,temp);if(c=c)num1=0;num2=0;flag=1;strcpy(str2,);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=Q)exit(0);putimage(x,y,rar,XOR_PUT);return;void mwindow( char *header )int height;cleardevice();setcolor( MaxColors - 1 );setviewport( 20, 20, MaxX/2, MaxY/2, 1 );height = textheight( H );settextstyle( DEFAULT_FONT, HORIZ_DIR, 1 );settextjustify( CENTER_TEXT, TOP_TEXT );outtextxy( MaxX/4, 2, header );setviewport( 20,20+height+4, MaxX/2+4, MaxY/2+20, 1 );drawboder();void drawboder(void)struct viewporttype vp;setcolor( MaxColors - 1 );setlinestyle( SOLID_LINE, 0, NORM_WIDTH );getviewsettings( &vp );rectangle( 0, 0, vp.right-vp.left, vp.bottom-vp.top ); int arrow()int size;int raw=4,4,4,8,6,8,14,16,16,16,8,6,8,4,4,4;setfillstyle(SOLID_FILL,2);fillpoly(8,raw);size=imagesize(4,4,16,16);rar=malloc(size);getimage(4,4,16,16,rar);putimage(4,4,rar,XOR_PUT);return 0;/ int specialkey(void)int key;while(bioskey(1)=0);key=bioskey(0);key=key&0xff? key&0xff:key8;return(key);总结:1) 实际操作过程中遇到的问题及解决方法:1. 忘记加分号。分号是C语句中不可缺少的一部分,语句末尾必须有分号。a=1 b=2编译时, 编译程序在“a=1”后面没发现分号,就把下一行“b=2”也作为上一行语句的一部分,这 就会出现语法错误。改错时,有时在被指出有错的一行中未发现错误,就需要看一下上一行 是否漏掉了分号。 z=x+y;t=z/100;printf(%f,t);对于复合语句来说,最后一个语句中最后 的分号不能忽略不写(这是和PASCAL不同的)。2. 输入输出的数据的类型与所用格式说明符不一致int a=3;float b=4.5;printf( “f%dn” ,a,b); 它们并不是按照赋值的规则进行转换(如把4.5转换为4),而是将数据在存储单元中的形式按 格式符的要求组织输出(如b占4个字节,只把最后两个字节的数据按小,作为整数输出)2)设计总结及心得体会。通过 C 语言编程的学习,培养了我独立思考和综合运用平时知识的能力,巩固了课程学 习的内容,掌握了工程软件设计的基本方法,强化了上机动手编程能力。更加了解了 C 语 言的便利性和可用性。同时了解到了程序设计需要团队合作,通过这次实习活动增进了同学 之间的默契,体会到了毕业后工作中团队合作的重要性和必要性。当一个程序从自己的手中诞生的时候,心中充满了自豪感和成就感,让我对动手操作实践更有兴趣了。八、时间:一周课时:12学时
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 解决方案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!