#include<stdio.h>
#include<math.h>
float newx()
{
float x;
printf("请输入x的值:");
scanf("%f",&x);
return x;
}
float newy()
{
float y;
printf("请输入y的值:");
scanf("%f",&y);
return y;
}
float add(float m,float n)
{
return (m+n);
}
float sub(float m,float n)
{
return n-m;}
float mul(float m,float n)
{
return m*n;}
float div(float m,float n)
{
if(n==0)printf("ERROR!\n");
return n/m;}
float Sin(float n)
{return sin(n);}
float Cos(float n)
{return cos(n);}
float Tan(float n)
{
return tan(n);}
float Exp(float n)
{
return exp(n);}
float Fabs(float n)
{
return fabs(n);}
float Log( float n)
{
return log(n);}
float Log10(float n)
{
return log10(n);
}
float Pow(float m,float n)
{
return pow(m,n);
}
float Sqrt(float n)
{
if(n<0)printf("ERROR!\n");
return sqrt(n);
}
void main()
{int sel;
printf("请选择计算方式:\n");
printf("1:\'+\' 2:\'-\' 3:\'*\' 4:\'/\' 5:\'sin\' 6:\'cos\' 7\'tan\'\n");
printf("8:\'exp\' 9:\'fabs\' 10:\'LogE\' 11:\'Log10\ 12:\'pow\' 13:\'Sqrt\'\n");
scanf("%d",&sel);
do
{
switch(sel)
{ case 0:break;
case 1:
printf("%.1f\n",add(newy(),newx()));break;
case 2:
printf("%.1f\n",sub(newy(),newx()));break;
case 3:
printf("%.1f\n",mul(newy(),newx()));break;
case 4:
printf("%.1f\n",div(newy(),newx()));break;
case 5:
printf("%.1f\n",Sin(newx()));break;
case 6:
printf("%.1f\n",Cos(newx()));break;
case 7:
printf("%.1f\n",Tan(newx()));break;
case 8:
printf("%.1f\n",Exp(newx()));break;
case 9:
printf("%.1f\n",Fabs(newx()));break;
case 10:
printf("%.1f\n",Log(newx()));break;
case 11:
printf("%.1f\n",Log10(newx()));break;
case 12:
printf("%.1f\n",Pow(newx(),newy()));break;
case 13:
printf("%.1f\n",Sqrt(newx()));break;
}
scanf("%d",&sel);
}while(sel!=0);
}