.net

不知不觉的就进入的.net的学习中,都说.net‘学起简单,但是我却不这样认为,要说简单也简单,就是很多理论性的东西有点难。毕竟也是才开始接触!觉得好多都是理论,需要理解,靠背代码是没用的

我们余需要懂题意,找到解决的方法,理清思路,理解分析————写代码

例:

int n = 18;
            Console.Write(n + "=");
            while (true)
            {
                bool isFind = false;
                #region 判断n是不是质数
                for (int i = 2; i < n; i++)
                {
                    if (n % i == 0)
                    {
                        isFind = true;
                        break;
                    }
                }
                #endregion
                if (!isFind)
                {
                    Console.Write(n);
                    break;
                }
                for (int i = 2; i < n; i++)
                {
                    if (n % i == 0)
                    {
                        Console.Write(i+"×");
                        n = n / i;
                        break;
                    }
                }
            }

继续努力吧!!!

时间: 2024-10-10 06:25:17