2014-12-05 68 views
-3

与其他程序员一样我也是编程领域的新手,我想要在这个世界中生活,并在您的帮助下获得奖励。所以,我必须在Cmath中使用一个数学函数。C#数学函数

功能是

z1 = Sin2α + sin5α - Sin3α/cosα+1-2sin^2(2α) 
z2= √x^3 + 3/x^3 - 3 

我的结果为止...

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

namespace ConsoleApplication2 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 

      Console.WriteLine ("First Program"); 
      Console.WriteLine ("Enter an integer"); 
      int x; 
      x = int.Parse(Console.ReadLine()); 
      Console.WriteLine ("x = " + x); 
      Console.WriteLine("Enter a valid number"); 



      //Solving the functions 
      double a = double.Parse(Console.ReadLine()); //Read the angle in degrees 
      a = a/180 * Math.PI; 
      double z = (Math.Cos(a)) + (Math.Cos(2 * a)) + (Math.Sin(6 * a)) + (Math.Cos(7 * a)); 
      z = (x * x) + (2(x)) - (3) + (x + 1) * Math.Sqrt(x * x - 9)/(x * x) - (2(x)) - (3) + (x - 1) * Math.Sqrt(x * x - 9); 




      Console.WriteLine(z); 
+3

所有数学相关函数在'System.Math'类,因此'F = Math.Sin(2)...' – 2014-12-05 14:08:30

+0

该函数将不编译。没有“2Sin * Sin2”。根本没有意义。 – duffymo 2014-12-05 14:10:09

+2

Google搜索“C#数学函数”真的没有任何结果吗? – 2014-12-05 14:18:06

回答

2

据我了解,该公式可以如下实施;但是,这些条款是否按照要求放在括号内并不完全清楚。

double z1(double alpha) 
{ 
    return Math.Sin(2.0f * alpha) 
     + Math.Sin(5.0f * alpha) 
     - Math.Sin(3.0f * alpha)/Math.Cos(alpha) 
            + 1.0f + 2.0f * Math.Sin(2.0f * alpha); 
} 

double z2(double x) 
{ 
    return Math.Sqrt(x * x * x) + 3.0f/(x * x * x) - 3.0f; 
} 
+0

请再看看现在的问题。 – GUEngineer 2014-12-05 16:44:14