#include
#include
#include
int cls()
{
system("cls");
return 0;
}
int pause()
{
system("pause");
return 0;
}
int switchs(double a,double b,char s)
{
switch (s)
{
case '+':
{
cls();
printf("a+b\n");
Sleep(500);
printf("=%0.3lf+%0.3lf\n",a,b);
Sleep(500);
printf("=%0.3lf\n\007",a+b);
Sleep(500);
}break;
case '-':
{
cls();
printf("a-b\n");
Sleep(500);
printf("=%0.3lf-%0.3lf\n",a,b);
Sleep(500);
printf("=%0.3lf\n\007",a-b);
Sleep(500);
}break;
case '*':
{
cls();
printf("a*b\n");
Sleep(500);
printf("=%0.3lf*%0.3lf\n",a,b);
Sleep(500);
printf("=%0.3lf\n\007",a*b);
Sleep(500);
}break;
case '/':
{
if(b==0)
{
cls();
printf("³ýÊý²»ÄÜΪ0£¡\n\007");
Sleep(500);
goto R;
}
else
{
cls();
printf("a/b\n");
Sleep(500);
printf("=%0.3lf/%0.3lf\n",a,b);
Sleep(500);
printf("=%0.5lf\n\007",a/b);
Sleep(500);
}
}break;
default:
{
cls();
printf("error!\n\007");
Sleep(500);
pause();
cls();
goto R;
}
}
R:;
}
int main(void)
{
char c;
double a,b;
char s;
R: printf("\007please input a formula:\n");
scanf("%lf%c%lf",&a,&s,&b);
if(a==0||b==0||s=='\0')printf("Error!");
else switchs(a,b,s);
pause();
while((c = getchar()) != '\n' && c != EOF);
a=0;b=0;s='\0';
cls();
goto R;
}