作业帮 > 综合 > 作业

c语言 多功能计算器多功能计算器实现以下功能:1)整数的加、减、乘、除2)实数的加、减、乘、除3)分数的计算.将分数定义

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/09 05:03:32
c语言 多功能计算器
多功能计算器
实现以下功能:
1)整数的加、减、乘、除
2)实数的加、减、乘、除
3)分数的计算.将分数定义为两个整数之比,如:1/2,3/4,24/48,64/2等;分数也可以是负数,如-1/2,15/-24;分数运算结果要是最简化的,如:4/-8,应表示成等价的-1/2.
4)复数的加、减、乘、除
(最好有注释,
#include "dos.h"
#include "math.h"
#include "conio.h"
#include "stdio.h"
#include "stdlib.h"
#include "stdarg.h"
#include "graphics.h"
#include "string.h"
#include "ctype.h"
#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 fond,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:%s\n",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 cnum[5],str2[20]={""},c,temp[20]={""};
char str1[]="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;j8;
return(key);
}
再问: 最好有注释,谢谢