数学Cos() 是一个内置的数学类方法,它返回给定双值参数(指定角度)的余弦。 语法:
null
public static double Cos(double num)
参数:
号码: 它是要返回其余弦的角度(以弧度为单位),该参数的类型为 系统双重的 .
返回值: 返回类型num的余弦 系统双重的 .如果num等于 否定、肯定或否定 ,则该方法返回 楠 . 下面是说明数学的程序。Cos()方法。 项目1: 来展示数学的运算能力。Cos()方法。
CSharp
// C# program to demonstrate working // Math.Cos() method using System; class Geeks { // Main Method public static void Main(String []args) { double a = 70; // converting value to radians double b = (a * (Math.PI)) / 180; // using method and displaying result Console.WriteLine(Math.Cos(b)); a = 50; // converting value to radians b = (a * (Math.PI)) / 180; // using method and displaying result Console.WriteLine(Math.Cos(b)); a = 73; // converting value to radians b = (a * (Math.PI)) / 180; // using method and displaying result Console.WriteLine(Math.Cos(b)); a = 77; // converting value to radians b = (a * (Math.PI)) / 180; // using method and displaying result Console.WriteLine(Math.Cos(b)); } } |
输出:
0.3420201433256690.6427876096865390.2923717047227370.224951054343865
项目2: 来展示数学的运算能力。当参数为 NaN或无穷大 .
CSharp
// C# program to demonstrate working // Math.Cos() method in infinity case using System; class Geeks { // Main Method public static void Main(String []args) { double positiveInfinity = Double.PositiveInfinity; double negativeInfinity = Double.NegativeInfinity; double nan = Double.NaN; double result; // Here argument is negative infinity, // output will be NaN result = Math.Cos(negativeInfinity); Console.WriteLine(result); // Here argument is positive infinity, // output will also be NaN result = Math.Cos(positiveInfinity); Console.WriteLine(result); // Here argument is NaN, output will be NaN result = Math.Cos(nan); Console.WriteLine(result); } } |
输出:
NaNNaNNaN
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END