输入数据为double双精度类型。最好直接给代码。用S1~S10表示文本框~谢谢~
追答public partial class _Default : System.Web.UI.Page
{
double[] a = new double[10];
TextBox[] s = new TextBox[10];
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < s.Length; i++)
{
s[i] = new TextBox();
this.Page.Form.Controls.Add(s[i]);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
for (int j = 0; j < s.Length; j++)
{
if (s[j].Text != "")
a[j] = float.Parse(s[j].Text);
else
a[j] = 1.0E+6;
}
double temp=1.0E+6;
for (int k = 0; k < s.Length; k++)
{
if (a[k] < temp)
temp = a[k];
}
Response.Write("最小数位:" + temp );
}
}
楼主往页面上添一个Button就行了,textbox不用添了
double [] NumArry = {p1,p2,p3,p4,p5,p6,p7,p8,p9,p10};
double minNum = NumArry[0];
for (int i = 0; i < NumArry.Length; i++)
{
if(NumArry[i]!=0)
{
minNum=NumArry[i];
break;
}
}
for (int i = 1; i < NumArry.Length; i++)
{
if(NumArry[i]!=0)
{
if (NumArry[i] < minNum)
{ //循环判断小
minNum=NumArry[i];
}
}
}