关于数学函数SIN COS....
using System;using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Math;
namespace WebApplication3
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Title = "转向梯形优化设计";
}
static float Add(float a, float b, float c, float d, float g)
{
float n;
int i;
for (i = 1; i <= 10; i++)
n += 1.5 * ((b * Math.PI / 180 - Math.Asin(Math.Sin((b + i) * Math.PI / 180) / Math.Sqrt(c * c / d / d + 1 - 2 * c * Math.Cos((b + i) * Math.PI / 180) / d)) - Math.Acos((c * (2 * Math.cos(b * Math.PI / 180) - Math.Cos((b + i) * Math.PI / 180)) / d - Math.Cos(2 * b * Math.PI / 180)) / (Math.Sqrt(c * c / d / d + 1 - 2 * c * Math.Cos((b + i) * Math.PI / 180))))) / Math.Atan(1 / (1 / Math.Tan(i * Math.PI / 180) - c / g)) - 1); for (i = 11; i <= 20; i++)
n += 1 * ((b * Math.PI / 180 - Math.Asin(Math.Sin((b + i) * Math.PI / 180) / Math.Sqrt(c * c / d / d + 1 - 2 * c * Math.Cos((b + i) * Math.PI / 180) / d)) - Math.Acos((c * (2 * Math.cos(b * Math.PI / 180) - Math.Cos((b + i) * Math.PI / 180)) / d - Math.Cos(2 * b * Math.PI / 180)) / (Math.Sqrt(c * c / d / d + 1 - 2 * c * Math.Cos((b + i) * Math.PI / 180))))) / Math.Atan(1 / (1 / Math.Tan(i * Math.PI / 180) - c / g)) - 1);
for (i = 21; i <= a; i++)
n += 0.5 * ((b * Math.PI / 180 - Math.Asin(Math.Sin((b + i) * Math.PI / 180) / Math.Sqrt(c * c / d / d + 1 - 2 * c * Math.Cos((b + i) * Math.PI / 180) / d)) - Math.Acos((c * (2 * Math.cos(b * Math.PI / 180) - Math.Cos((b + i) * Math.PI / 180)) / d - Math.Cos(2 * b * Math.PI / 180)) / (Math.Sqrt(c * c / d / d + 1 - 2 * c * Math.Cos((b + i) * Math.PI / 180))))) / Math.Atan(1 / (1 / Math.Tan(i * Math.PI / 180) - c / g)) - 1);
return n;
}
protected void Button1_Click(object sender, EventArgs e)
{
float a, b, c, d, g, n;
a = float.Parse(TextBox7.Text);
b = float.Parse(TextBox3.Text);
c = float.Parse(TextBox2.Text);
d = float.Parse(TextBox4.Text);
g = float.Parse(TextBox1.Text);
n = Add(a, b, c, d, g);
Label1.Text = "结果:" + n.ToString();
}
}
}
我这么写是哪里出错呢?
错误提示 using 命名空间指令只能应用于命名空间;"system.math"是一个类型 而不是命名空间
或者是我数学公式那个地方写错了?不然应该怎么写呢?
请大家给我指点一下 拜托! --------------------编程问答-------------------- 删除这行:
using System.Math;
--------------------编程问答-------------------- Math就在 System 命名空间下,静态类 Math即可。引用多余了。 --------------------编程问答-------------------- 建议重新梳理下程序,比如写一个函数来处理Cos(角度)。
主程序代码简化下。否则很难阅读和修改。 --------------------编程问答-------------------- 你的using System.Math;是多余了。
因为你下面用的时候是Math.Cos...等
如果你直接用Cos...那就得写using 。。。 --------------------编程问答--------------------
删除这行后
错误提示是“system.math并不包含COS的定义”
--------------------编程问答--------------------
注意大小写。 --------------------编程问答-------------------- 删除using System.Math;
cos的正确写法是 Math.Cos
System.Math不是一个命名空间,所以不能用using System.Math --------------------编程问答-------------------- 谢谢啦!终于弄好了!多谢!!!
补充:.NET技术 , C#