C语言毕业课程设计报告计算器Word文档格式.docx
- 文档编号:18622095
- 上传时间:2022-12-29
- 格式:DOCX
- 页数:37
- 大小:161.45KB
C语言毕业课程设计报告计算器Word文档格式.docx
《C语言毕业课程设计报告计算器Word文档格式.docx》由会员分享,可在线阅读,更多相关《C语言毕业课程设计报告计算器Word文档格式.docx(37页珍藏版)》请在冰豆网上搜索。
本程序包含两个模块:
1)主程序模块:
voidmain()//cal.c
{
各种宏定义;
欢迎界面;
图像的初始化;
do{
接受键盘和鼠标输入的命令;
处理命令;
}while(“命令”=“结束”)
}
2)鼠标调用的界面模块//mouse.h
各模块之间的调用关系如下:
三、详细设计
1、主要函数
(1)、主控模块main.c
voidinitialmouse(void);
/*初始化鼠标函数*/
doublechar_to_float(char*p);
/*字符转换成浮点数*/
voidwelcome();
/*欢迎界面*/
(2)、鼠标头文件mouse.c
voidmouse();
//接受鼠标的按键信息
intrmouse(void)//初始化鼠标图像图标,并且返回是否成功的信息
showmouse()//利用不断复制和粘贴图像的方法来动态显示鼠标光标
hidemouse()//关闭光标
getmousecoods()//得到鼠标当前的信息
voidmovemouse(intx,inty);
//确定鼠标的位置
Area(intx0,inty0,intx1,inty1)//设置鼠标移动的位置范围
guangbiao(intx,inty)//画出光标
2、函数的主要调用关系图
四、调试分析及编程心得体会
1、刚开始的时候不习惯于结构话编程,没有严格按单元模块结构编写不善于构建子函数来简化和理清楚编程思路,可读性几乎为零!
!
2、刚开始时在鼠标功能的区域选择的宏定义中花了较大功夫,程序容错性较差。
3、对处理字符串的复杂处理方法费时较多,并且表达的混乱。
4、由于初次进行系统的程序设计,层次结构划分不太合理,没有结构化编程的经验和体会,应在以后中加强实践,提高能力。
………………………………………………………………………………………………………………
五、用户手册
1、本程序的运行环境为DOS操作系统,执行文件为cal.exe。
2、进入演示程序后即先显示欢迎界面再进入图像模式的用户界面
(1)1exp
(2)80-50
(3)2/1(4)7+8=
六、测试结果
七、源程序代码
/*******************************************************
1、main.c主控文件
*******************************************************
#include<
stdio.h>
//头文件
stdlib.h>
math.h>
graphics.h>
#include"
time.h"
alloc.h"
mouse.h"
/*鼠标函数调用模块*/
dos.h"
intkey,dian=0,x,y;
charch='
0'
;
charemp[80],sum[80],*e,*s;
doubleyuan=0.;
select()
if(where_chu)key=47;
elseif(where_cheng)key=42;
elseif(where_jian)key=45;
elseif(where_jia)key=43;
elseif(where_num1)key=49;
elseif(where_num2)key=50;
elseif(where_num3)key=51;
elseif(where_enter)key=ENTER;
elseif(where_num4)key=52;
elseif(where_num5)key=53;
elseif(where_num6)key=54;
elseif(where_dot)key=46;
elseif(where_num7)key=55;
elseif(where_num8)key=56;
elseif(where_num9)key=57;
elseif(where_num0)key=48;
elseif(where_kai)key=32;
elseif(where_guan)key=EXCAPE;
elseif(where_fuhao)key=MINUS;
elseif(where_zhishu)key=EXP;
elsekey=0;
}
voidwelcome()/*欢迎界面*/
char*Info="
\n\n\n\
\n\Welcometousethiscalculator!
\
\n\
Inthiscalculator,bothkeyboardandmousecanbeused.\n\n\
KEYS:
ThankstoMyBOBO,hedidmuchtohelpmeindeed.\n\
Ihavealsodownloadedsomematerialsfrominternet.\n\
Butitwasreallyanefforformetomakethosethingsclear.\n\
Ihopeyouwillloveit.\n\n\
\n\
\n\n\
GOODLUCK!
\0"
while(*Info++!
='
\0'
&
bioskey
(1)==0)
{
sound(300);
nosound();
printf("
%c"
*(Info-1));
delay(10000);
}
voidmain()
{
voidinitialmouse(void);
/*初始化鼠标*/
doublechar_to_float(char*p);
/*浮点数转换成浮点数*/
inti,flag=0;
/*输入结果标记*/
doublet;
intinput();
intgd=DETECT,gm;
initgraph(&
gd,&
gm,"
"
);
/*初始化屏幕为图形模式*/
rmouse();
/*初始化鼠标*/
Area();
e=emp;
s=sum;
welcome();
initialmouse();
x=120;
/*结果输出位置*/
y=1;
while
(1)/*始终记录用户的命令和操作*/
{
reg_b=0;
do{
showmouse();
/*显示鼠标的光标*/
if(reg_b)select();
/*检测鼠标的左键按钮*/
}while(reg_b==0&
bioskey
(1)==0);
if(bioskey
(1)!
=0)key=input();
switch(key)/*各种操作功能选择*/
{
caseEXCAPE:
bar(guan);
delay(8000);
initialmouse();
exit(0);
case47:
/*³
ý
·
¨
*/
bar(chu);
if(ch!
{
switch(ch)
{
case'
/'
:
{
if(char_to_float(emp)==0.0)
{
ch='
flag=0;
dian=0;
emp[0]='
sum[0]='
e=emp;
s=sum;
outtextxy(x+30,y+40,"
error!
!
break;
}
yuan=char_to_float(sum)/char_to_float(emp);
sprintf(sum,"
%0.10f"
yuan);
outtextxy(x+38,y+40,sum);
break;
}
*'
/*³
Ë
*/
yuan=char_to_float(sum)*char_to_float(emp);
outtextxy(x+30,y+40,sum);
+'
/*¼
Ó
yuan=char_to_float(sum)+char_to_float(emp);
-'
õ
if(char_to_float(sum)>
=char_to_float(emp))
yuan=char_to_float(sum)-char_to_float(emp);
sprintf(sum,"
}
else{
yuan=char_to_float(emp)-char_to_float(sum);
-%0.10f"
emp[0]='
}
}
}
else{
if(flag==0)
{
outtextxy(x+30,y+40,emp);
stpcpy(sum,emp);
}
elseouttextxy(x+30,y+40,sum);
}
ch='
flag=0;
emp[0]='
e=emp;
dian=0;
break;
case42:
/*°
´
Ï
Â
*º
Å
*/
{
bar(cheng);
if(ch!
switch(ch)
case'
yuan=char_to_float(sum)/char_to_float(emp);
outtextxy(x+30,y+40,sum);
yuan=char_to_float(sum)*char_to_float(emp);
yuan=char_to_float(sum)+char_to_float(emp);
case'
if(char_to_float(sum)>
{
yuan=char_to_float(sum)-char_to_float(emp);
sprintf(sum,"
}
else{
yuan=char_to_float(emp)-char_to_float(sum);
sprintf(sum,"
outtextxy(x+30,y+40,sum);
emp[0]='
e=emp;
break;
}
else
e=emp;
else
outtextxy(x+30,y+40,sum);
ch='
flag=0;
dian=0;
break;
case45:
/*°
-º
bar(jian);
switch(ch){
case'
yuan=char_to_float(sum)/char_to_float(emp);
sprintf(sum,"
outtextxy(x+30,y+40,sum);
emp[0]='
e=emp;
yuan=char_to_float(sum)*char_to_float(emp);
case'
yuan=char_to_float(sum)+char_to_float(emp);
if(char_to_float(sum)>
=char_to_float(emp)){
yuan=char_to_float(sum)-char_to_float(emp);
else{
yuan=char_to_float(emp)-char_to_float(sum);
outtextxy(x+30,y+40,sum);
if(flag==0)
outtextxy(x+30,y+40,emp);
stpcpy(sum,emp);
}
else
case43:
bar(jia);
delay(8000);
initialmouse();
){
switch(ch){
yuan=char_to_float(sum)/char_to_float(emp);
sprintf(sum,"
yuan=char_to_float(sum)*char_to_float(emp);
yuan=char_to_float(sum)+char_to_float(emp);
if(char_to_float(sum)>
yuan=char_to_float(sum)-char_to_float(emp);
yuan=char_to_float(emp)-char_to_float(sum);
if(flag==0)
outtextxy(x+30,y+40,sum);
m'
bar(fuhao);
for(i=0;
i<
=79;
i++)
if(emp[i]=='
)
break;
if(flag==0){
*e='
e++;
*e='
elseouttextxy(x+30,y+40,sum);
case49:
1*/
bar(num1);
bre
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 毕业 课程设计 报告 计算器
![提示](https://static.bdocx.com/images/bang_tan.gif)