计算反三角函数程序代码(有菜单)

这是个计算反三角函数的小程序,至于做这个程序的原因是电脑的计算器没有反三角函数。。。
一下是C语言的代码:
#include
#include
#include

void main()
{
double a;
int flag;
Menu:
printf("Please choose the funciton that you want:\n1 arcsin\t2 arccos\t3 arctan\n");
scanf("%d",&flag);
switch(flag)
{
case 1:
printf("Welcome!This funciton is named arcsin.Now you can input a num!\nYou can input 9527 to return the Menu.\n");
while(1)
{
scanf("%lf",&a);
if(a == 9527) goto Menu;
else
if(a > 1 || a < -1)
{
printf("Sorry,our functions can't support you num,please input again!\n");
continue;
}
else printf("arcsinx = %lf\n",asin(a));
system("pause");
}
case 2:
printf("Welcome!This funciton is named arccos.Now you can input a num!\nYou can input 9527 to return the Menu.\n");
while(1)
{
scanf("%lf",&a);
if(a == 9527) goto Menu;
else
if(a > 1 || a < -1)
{
printf("Sorry,our functions can't support you num,please input again!\n");
continue;
}
else printf("arccosx = %lf\n",acos(a));
system("pause");
}
case 3:
printf("Welcome!This funciton is named arctan.Now you can input a num!\nYou can input 9527 to return the Menu.\n");
while(1)
{
scanf("%lf",&a);
if(a == 9527) goto Menu;
else
printf("arctanx = %lf\n",atan(a));
system("pause");
}
default :printf("The number you input is error!Please input again!\n");
system("pause");
goto Menu;
}
}

相关文档
最新文档