毕氏定理!?

找出1~1000数字中的勾股数。
勾股数是由三个正整数组成的数组;
能符合勾股定理(毕式定理)「a2 + b2 = c2 」之中, (a, b, c) 的整数解。
老实说,这我只会用穷举法来计算~也就是傻傻地从1开始算~~~~哈哈哈哈哈哈!!

 class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入4位数整数:");
            int x = Convert.ToInt32(Console.ReadLine());

            Stopwatch tt = new Stopwatch();
            tt.Start();

            //运行的程式
            getGoNum(x);

            tt.Stop();
            Console.WriteLine("程式执行完成时间共{0}ms.", tt.ElapsedMilliseconds);
            Console.ReadLine();
        }

        public static void getGoNum(int MaxNum)
        {
            for (int i = 1; i < MaxNum; i++)
            {
                for (int j = i + 1; j < MaxNum; j++)
                {
                    for (int n = j + 1; n < MaxNum; n++)
                    {
                        if ((i * i + j * j) == n * n)
                        {
                            Console.WriteLine(String.Format("满足 a平方 * b平方 = c平方 {0} {1} {2} ", i, j, n));

                        }
                    }
                }

            }
        }
    }

跑起来挺花时间的~
毕竟一个一个慢慢算阿~~
数字越大跑得越久~~~~

水滴可成涓流,涓流可成湖泊大海。
汲取累积知识,将知识堆积成常识;将常识探究成学识;将学识简化为知识;授人自省。