24664人加入学习
(72人评价)
C#编程-第一季-编程基础-宇宙最简单2021最新版

制作完成于2021年10月10日,使用Visual Studio 2019

价格 免费

static bool Issu(int number){
bool isSu = true;
for (int j = 2;j< nunber-1;j++)//2~i-1

{
if(number %j=0){
isSu = false;

return issu;
}
}
return issu;
}

[展开全文]
 static bool IsSu(int number)
        {
            bool isSu = true;
            for (int j = 2; j < number-1; j++)
            {

                if (number% j == 0)
                {
                    isSu = false;
                    break;
                }
            }
            return isSu;
        }
        static int opposite(int number)//反序
        {
            int temp = number;
            int num = 0;
            while (temp % 10 != 0)//反序
            {
                num = num * 10 + temp % 10;
                temp = temp / 10;
            }     
            return num;           
        }
        static void test01()
        {
            string str = Console.ReadLine();
            string[] strArray = str.Split(' ');
            int[] intArray = new int[strArray.Length];
            for (int j = 0; j < strArray.Length; j++)
            {
                int number = Convert.ToInt32(strArray[j]);
                intArray[j] = number;
            }
            int m = intArray[0];
            int n = intArray[1];
            for (int i = m; i <= n; i++)
            {
                bool isSu =IsSu(i);
                //for (int j = 2; j < i; j++)
                //{

                //    if (i % j == 0)
                //    {
                //        issu = false;
                //        break;
                //    }
                //}
                if (isSu)
                {
                    //int temp = i;
                    //int num = 0;
                    //while (temp % 10 != 0)//反序
                    //{
                    //    num = num * 10 + temp % 10;
                    //    temp = temp / 10;
                    //}
                    int temp = i;
                    int num = opposite(temp);
                    bool isSuFan = IsSu(num);                  
                    //for (int j = 2; j < num; j++)
                    //{
                    //    if (num % j == 0)
                    //    {
                    //        isSuFan = false;
                    //        break;
                    //    }
                    //}
                    if (isSuFan == true)
                    {
                        Console.Write(i + " ");
                    }
                }              
            }           
        }

 

[展开全文]

return 用来结束当前函数,并把某个结果返后  

[展开全文]

授课教师

SiKi学院老师

课程特色

下载资料(1)
视频(118)
图文(1)