日期:2014-05-20 浏览次数:21303 次
                decimal A = 4;
                decimal B = 1;
                int IndexA = 1;
                int IndexB = 1;
                
                ArrayList arry = new ArrayList();
                int FindIndex = 3;
                int n = 0;
                while (n < FindIndex)
                {
                    if (IndexA * (A + B) < IndexB * (A - B))
                    {
                        arry.Add(IndexA * (A + B));
                        IndexA = IndexA + 2;
                    }
                    else
                    {
                        arry.Add(IndexB * (A - B));
                        IndexB = IndexB + 2;
                    }
                    n++;
                }
                Console.Write(decimal.Parse(arry[FindIndex - 1].ToString()) / ((A - B) * (A + B)));
                Console.ReadLine();
------解决方案--------------------
double A = Convert.ToDouble(this.textBox1.Text); //输入A数的值
            double B = Convert.ToDouble(this.textBox2.Text); //输入B数的值
            int N = Convert.ToInt32(this.textBox3.Text); //要求的N个数
            List<double> list=new List<double>();
            double tempAdd = 0;
            double tempSub = 0;
            for (int i = 1, j = 0; j < N; i = i + 2, j++)
            {
                tempAdd = i / (A + B);
                tempSub = i / (A - B);
                list.Add(tempAdd);
                list.Add(tempSub);
            }
            list.Sort(); //从低道高排序
            this.textBox4.Text = list[N].ToString(); //输出结果