谁有小型计算器的程序?单片机是ATmega16的
答案:3 悬赏:0 手机版
解决时间 2021-04-29 08:07
- 提问者网友:喧嚣尘世
- 2021-04-28 17:20
最好是用数组的。没有,别的也行。!
100内的加减乘除
谢谢!!!
最佳答案
- 五星知识达人网友:患得患失的劫
- 2021-04-28 18:16
#include"string.h"
#include"graphics.h"
#include"conio.h"
#include"dos.h"
#include"time.h"
#include"stdlib.h"
#include"stdio.h"
#include"math.h"
int py;
void mode(int py)
{ double x1,x2,ans,ans2;
if(py<11)
{ printf("input x1,x2:");
scanf("%lf,%lf",&x1,&x2); }
else {printf("input x:");scanf("%lf",&x1);}
switch(py)
{ case 6 : ans=x1+x2;printf("=%.3lf",ans);break;
case 7 : ans=x1-x2;printf("=%.3lf",ans);break;
case 8 : ans=x1*x2;printf("=%.3lf",ans);break;
case 9 : ans=x1/x2;printf("=%.3lf",ans);break;
case 10 : ans=pow(x1,x2);printf("x^%.1lf=%.3lf",x2,ans);break;
case 11 : ans=sqrt(x1);printf("=%.3lf",ans);break;
case 12 : ans=sin(x1);ans2=cos(x1);printf("sin x=%.3lf,cos x=%.3lf",ans,ans2);break;
case 13 : ans=asin(x1);ans2=acos(x1);printf("asin x=%.3lf,acos x=%.3lf",ans,ans2);break;
}
getch();clrscr();
}
int join(char *ps)
{ char name[30],pass[20];
int len,i;
printf("ID:");
scanf("%s",name);
printf("\npass word:");
scanf("%s",pass);
clrscr();
for(i=0;i<strlen(ps);i++)
if(pass[i]!=*(ps+i)) return 0;
return 1;
}
int menu(int pass)
{int py=6;char key=0;
gotoxy(1,4);
printf("MENU\n\n");
printf("ADD +\n");
printf("SUB -\n");
printf("MUL *\n");
printf("DIV /");
gotoxy(10,6);printf("<-");
if(pass) {gotoxy(1,10);printf("INV ^\n");
printf("EVO ~\n");
printf("SIN COS\n");
printf("ASIN ACOS\n");
printf("modify\n");
printf("QUIT"); }
else {gotoxy(1,10);printf("QUIT");}
while(key!=13)
{ key=getch();
switch(key)
{ case 80 : gotoxy(10,py);printf(" ");if(!pass) py=py%5+6; else {++py;if(py==16) py=6;}break;
case 72 : gotoxy(10,py);printf(" ");--py; if(py==5) py=10+5*pass; break;
}
gotoxy(10,py);printf("<-");
}
return py;
}
main()
{ int gd=DETECT,gm,x=320,y=10,i,l=10,h=10,t,co=3,v=0;
int pass;
FILE *fp;char ps[20];
initgraph(&gd,&gm,"");
registerbgidriver(EGAVGA_driver);
for(i=1;i<31;co=(co++%10),v++,y+=2+v,i++)
{ delay(9e10);cleardevice();
setcolor(co);
setfillstyle(1,co);
sector(x,y,0,360,l,h);
}
for(i=1;i<300;i++)
{ setcolor(i%10);
circle(x,y,i);
delay(1000);
}
cleardevice();
closegraph();
fp=fopen("file1","r");
if(fp==NULL) pass=1;
else {fgets(ps,20,fp);
pass=join(ps);}
ld: py=menu(pass);
if(py==pass*5+10) {clrscr();printf("bye bye!");getch();return 0;}
else if(py!=14){clrscr();mode(py);} else { fp=fopen("file1","w");
printf("\npass word:");
scanf("%s",ps);
fputs(ps,fp);
fclose(fp); getch();clrscr();
}
goto ld;
}
全部回答
- 1楼网友:封刀令
- 2021-04-28 21:07
简单点。。。上网查很多的。。。我就是刚刚去百度搜就是了,很多。
- 2楼网友:患得患失的劫
- 2021-04-28 19:55
在电脑里面常用工具里面有啊
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯