角度制下的反三角函数计算程序
VB.NET
①
Module ArcTrigonoDim F, o, x, d, m, s As PrimitiveSub Main()F(1) = "arcsin(x) = "F(2) = "arcsec(x) = "F(3) = "arccos(x) = "F(4) = "arccsc(x) = "F(5) = "arctan(x) = "F(6) = "arccot(x) = "Start:TextWindow.Clear()TextWindow.WriteLine("① arcsin(x)")TextWindow.WriteLine("② arcsec(x)")TextWindow.WriteLine("③ arccos(x)")TextWindow.WriteLine("④ arccsc(x)")TextWindow.WriteLine("⑤ arctan(x)")TextWindow.WriteLine("⑥ arccot(x)")TextWindow.Write("请选择:")o = TextWindow.ReadNumber()If o = 1 ThenInput()If Microsoft.SmallBasic.Library.Math.Abs(x) > 1 ThenTextWindow.WriteLine("定义域错误!")Elsed = Microsoft.SmallBasic.Library.Math.GetDegrees(Microsoft.SmallBasic.Library.Math.ArcSin(x))Output()End IfElseIf o = 2 ThenInput()If Microsoft.SmallBasic.Library.Math.Abs(x) < 1 ThenTextWindow.WriteLine("定义域错误!")Elsed = Microsoft.SmallBasic.Library.Math.GetDegrees(Microsoft.SmallBasic.Library.Math.ArcCos(1 / x))Output()End IfElseIf o = 3 ThenInput()If Microsoft.SmallBasic.Library.Math.Abs(x) > 1 ThenTextWindow.WriteLine("定义域错误!")Elsed = Microsoft.SmallBasic.Library.Math.GetDegrees(Microsoft.SmallBasic.Library.Math.ArcCos(x))Output()End IfElseIf o = 4 ThenInput()If Microsoft.SmallBasic.Library.Math.Abs(x) < 1 ThenTextWindow.WriteLine("定义域错误!")Elsed = Microsoft.SmallBasic.Library.Math.GetDegrees(Microsoft.SmallBasic.Library.Math.ArcSin(1 / x))Output()End IfElseIf o = 5 ThenInput()d = Microsoft.SmallBasic.Library.Math.GetDegrees(Microsoft.SmallBasic.Library.Math.ArcTan(x))Output()ElseIf o = 6 ThenInput()d = 90 - Microsoft.SmallBasic.Library.Math.GetDegrees(Microsoft.SmallBasic.Library.Math.ArcTan(x))End IfOutput()ElseGoto StartEnd IfEnd SubSub Input()TextWindow.Clear()TextWindow.Write("x = ")x = TextWindow.ReadNumber()End SubSub Output()TextWindow.Write(F(o))TextWindow.ForegroundColor = "Red"TextWindow.Write(d + "度")TextWindow.ForegroundColor = "Gray"TextWindow.Write(" = ")TextWindow.ForegroundColor = "Red"If d < 0 ThenTextWindow.Write("-")d = -dEnd Ifm = (d - Microsoft.SmallBasic.Library.Math.Floor(d)) * 60d = Microsoft.SmallBasic.Library.Math.Floor(d)s = (m - Microsoft.SmallBasic.Library.Math.Floor(m)) * 60m = Microsoft.SmallBasic.Library.Math.Floor(m)TextWindow.Write(d + "度")TextWindow.ForegroundColor = "Yellow"TextWindow.Write(m + "分")TextWindow.ForegroundColor = "Green"TextWindow.WriteLine(s + "秒")TextWindow.ForegroundColor = "Gray"End SubEnd Module
②
Module ArcTrigonoDim F, o, x, d, m, s As PrimitiveSub Main()F(1) = "arcsin(x) = "F(2) = "arcsec(x) = "F(3) = "arccos(x) = "F(4) = "arccsc(x) = "F(5) = "arctan(x) = "F(6) = "arccot(x) = "Start:TextWindow.Clear()TextWindow.WriteLine("① arcsin(x)")TextWindow.WriteLine("② arcsec(x)")TextWindow.WriteLine("③ arccos(x)")TextWindow.WriteLine("④ arccsc(x)")TextWindow.WriteLine("⑤ arctan(x)")TextWindow.WriteLine("⑥ arccot(x)")TextWindow.Write("请选择:")o = TextWindow.ReadNumber()If o = 1 ThenInput()If (x < -1) Or (x > 1) ThenTextWindow.WriteLine("定义域错误!")Elsed = Microsoft.SmallBasic.Library.Math.GetDegrees(Microsoft.SmallBasic.Library.Math.ArcSin(x))Output()End IfElseIf o = 2 ThenInput()If (x > -1) And (x < 1) ThenTextWindow.WriteLine("定义域错误!")Elsed = Microsoft.SmallBasic.Library.Math.GetDegrees(Microsoft.SmallBasic.Library.Math.ArcCos(1 / x))Output()End IfElseIf o = 3 ThenInput()If (x < -1) Or (x > 1) ThenTextWindow.WriteLine("定义域错误!")Elsed = Microsoft.SmallBasic.Library.Math.GetDegrees(Microsoft.SmallBasic.Library.Math.ArcCos(x))Output()End IfElseIf o = 4 ThenInput()If (x > -1) And (x < 1) ThenTextWindow.WriteLine("定义域错误!")Elsed = Microsoft.SmallBasic.Library.Math.GetDegrees(Microsoft.SmallBasic.Library.Math.ArcSin(1 / x))Output()End IfElseIf o = 5 ThenInput()d = Microsoft.SmallBasic.Library.Math.GetDegrees(Microsoft.SmallBasic.Library.Math.ArcTan(x))Output()ElseIf o = 6 ThenInput()d = 90 - Microsoft.SmallBasic.Library.Math.GetDegrees(Microsoft.SmallBasic.Library.Math.ArcTan(x))End IfOutput()ElseGoto StartEnd IfEnd SubSub Input()TextWindow.Clear()TextWindow.Write("x = ")x = TextWindow.ReadNumber()End SubSub Output()TextWindow.Write(F(o))TextWindow.ForegroundColor = "Red"TextWindow.Write(d)TextWindow.Write("度")TextWindow.ForegroundColor = "Gray"TextWindow.Write(" = ")TextWindow.ForegroundColor = "Red"If d < 0 ThenTextWindow.Write("-")d = -dEnd Ifm = (d - Microsoft.SmallBasic.Library.Math.Floor(d)) * 60d = Microsoft.SmallBasic.Library.Math.Floor(d)s = (m - Microsoft.SmallBasic.Library.Math.Floor(m)) * 60m = Microsoft.SmallBasic.Library.Math.Floor(m)TextWindow.Write(d)TextWindow.Write("度")TextWindow.ForegroundColor = "Yellow"TextWindow.Write(m)TextWindow.Write("分")TextWindow.ForegroundColor = "Green"TextWindow.Write(s)TextWindow.WriteLine("秒")TextWindow.ForegroundColor = "Gray"End SubEnd Module
JScript.NET
①
import System;var F=["定义域错误!","arcsin(x) = ","arcsec(x) = ","arccos(x) = ","arccsc(x) = ","arctan(x) = ","arccot(x) = "],o,x,d,m,s;for(;;){Console.Clear();Console.Write("① arcsin(x)\n② arcsec(x)\n③ arccos(x)\n④ arccsc(x)\n⑤ arctan(x)\n⑥ arccot(x)\n请选择:");o=Console.ReadLine();if(o==1){Input();if(Math.abs(x)>1)Console.WriteLine(F[0]);else{d=Math.asin(x)/Math.PI*180;Output();}break;}if(o==2){Input();if(Math.abs(x)<1)Console.WriteLine(F[0]);else{d=Math.acos(1/x)/Math.PI*180;Output();}break;}if(o==3){Input();if(Math.abs(x)>1)Console.WriteLine(F[0]);else{d=Math.acos(x)/Math.PI*180;Output();}break;}if(o==4){Input();if(Math.abs(x)<1)Console.WriteLine(F[0]);else{d=Math.asin(1/x)/Math.PI*180;Output();}break;}if(o==5){Input();d=Math.atan(x)/Math.PI*180;Output();break;}if(o==6){Input();d=90-Math.atan(x)/Math.PI*180;Output();break;}}function Input(){Console.Clear();Console.Write("x = ");x=Console.ReadLine();}function Output(){Console.Write(F[o]);Console.ForegroundColor=12;Console.Write(d+"度");Console.ForegroundColor=7;Console.Write(" = ");Console.ForegroundColor=12;if(d<0){Console.Write("-");d=-d;}m=(d-Math.floor(d))*60;d=Math.floor(d);s=(m-Math.floor(m))*60;m=Math.floor(m);Console.Write(d+"度");Console.ForegroundColor=14;Console.Write(m+"分");Console.ForegroundColor=10;Console.WriteLine(s+"秒");Console.ForegroundColor=7;}
②
import System;var F=["定义域错误!","arcsin(x) = ","arcsec(x) = ","arccos(x) = ","arccsc(x) = ","arctan(x) = ","arccot(x) = "],o,x,d,m,s;for(;;){Console.Clear();Console.Write("① arcsin(x)\n② arcsec(x)\n③ arccos(x)\n④ arccsc(x)\n⑤ arctan(x)\n⑥ arccot(x)\n请选择:");o=Console.ReadLine();if(o==1){Input();if(x<-1||x>1)Console.WriteLine(F[0]);else{d=Math.asin(x)/Math.PI*180;Output();}break;}if(o==2){Input();if(x>-1&&x<1)Console.WriteLine(F[0]);else{d=Math.acos(1/x)/Math.PI*180;Output();}break;}if(o==3){Input();if(x<-1||x>1)Console.WriteLine(F[0]);else{d=Math.acos(x)/Math.PI*180;Output();}break;}if(o==4){Input();if(x>-1&&x<1)Console.WriteLine(F[0]);else{d=Math.asin(1/x)/Math.PI*180;Output();}break;}if(o==5){Input();d=Math.atan(x)/Math.PI*180;Output();break;}if(o==6){Input();d=90-Math.atan(x)/Math.PI*180;Output();break;}}function Input(){Console.Clear();Console.Write("x = ");x=Console.ReadLine();}function Output(){Console.Write(F[o]);Console.ForegroundColor=12;Console.Write(d);Console.Write("度");Console.ForegroundColor=7;Console.Write(" = ");Console.ForegroundColor=12;if(d<0){Console.Write("-");d=-d;}m=(d-Math.floor(d))*60;d=Math.floor(d);s=(m-Math.floor(m))*60;m=Math.floor(m);Console.Write(d);Console.Write("度");Console.ForegroundColor=14;Console.Write(m);Console.Write("分");Console.ForegroundColor=10;Console.Write(s);Console.WriteLine("秒");Console.ForegroundColor=7;}
Forse altri canterà con miglior plettro.
