dos 计算器
#include<stdio.h>#define p printf
#define s scanf
#define g gotoxy
float num,ans;
char opp;
int y,z,d,a;
void designed(int x,int as,int x1),des();
main()
{
a:
ans=0;
des();
g(38,5);s("%f",&ans);
while(opp!='r')
{
b:
des();
if(ans>1000000)
{
g(2,10);p(" The system could not");
g(2,11);p(" proceed because the");
g(2,12);p(" Answer was already");
g(2,13);p(" greater than to");
g(2,14);p(" 1000000.");
g(2,15);p("Press any key !");
getch();
exit(0);
}
c:
g(38,4);s("%s",&opp);
if(opp=='=')
{
goto b;
}
else if(opp=='r')
{
opp=''; goto a;
}
des();
num=0;
g(38,5);s("%f",&num);
if(opp=='+')
{
ans=ans+num;
}
else if(opp=='-')
{
ans=ans-num;
}
else if(opp=='x')
{
ans=ans*num;
}
else if(opp=='/')
{
ans=ans/num;
}
else
{
des();
g(2,10);p(" The system could not");
g(2,11);p(" compute because you ");
g(2,12);p(" entered a wrong ");
g(2,13);p(" operator.");
goto c;
}
}
getche();
}
void des()
{
clrscr();
a=2;
a=9;
a=16;
designed(1,25,25);
a=6;
designed(37,19,55);
z=14;
g(39,z);
for(y=0;y<=9;y++)
{
p(" %i",y);
if(d==0)
{
delay(1000000);
}
if(y==0 || y==3 || y==6)
{
z=z-2;
g(39,z);
}
}
g(44,14);p(".=");
g(52,8);p("/");
g(52,10);p("x");
g(52,12);p("-");
g(52,14);p("+");
g(9,1);p("Operator");
g(41,1);p("Calculator");
g(3,3);p("Addition = +");
g(3,4);p("Subtraction = -");
g(3,5);p("Division = /");
g(3,6);p("Multiplication = x");
g(3,7);p("Equals = =");
g(3,8);p("Reset = r");
g(28,3);p("Answer");
g(27,4);p("Operator");
g(28,5);p("Number");
d=1;
g(38,3);p("%f",ans);
g(38,4);p("%c",opp);
}
void designed(int x,int as,int x1)
{
for(y=2;y<=16;y++)
{
if(y==a || y==a || y==a)
{
g(x,y);
for(z=0;z<as;z++)
{
p("*");
if(d==0)
{
delay(1000000);
}
}
}
else
{
g(x,y); p("*");
if(d==0)
{
delay(1000000);
}
g(x1,y); p("*");
}
}
}
页:
[1]