Unity - A计划(永久有效期) 扫二维码继续学习 二维码时效为半小时

(196评价)
价格: 4049.00元
c# 第一季 编程基础 101节真素数问题
Ala000发起了问答2022-03-26
1
回复
250
浏览

比对了跟老师写的代码是一样的,为什么运行不起来,也没有报错

using System;

namespace _015
{
    class Program
    {
         static void Main(string[] args)
        {
            string c = Console.ReadLine();
            string []cc = c.Split(" ");
            int[] d = new int[cc.Length];

            for(int i = 0; i < cc.Length; i++)
            {
                int temp = Convert.ToInt32(cc[i]);
                d[i] = temp;
            }

            int n = d[0];
            int m = d[1];
            
            

            for (int i = n; i <= m; i++)
            {
                bool feisushu = false;
                
                for (int j = 2; j < i; j++)
                {
                    if (i % j == 0)
                    {
                        feisushu = true;
                        break;
                    }
                }
                
                if (feisushu == false)
                {
                    int mun = 0;
                    int temp = i;
                    while (i % 10 != 0)
                    {
                        mun = mun * 10 + temp % 10;
                        temp /= 10;
                    }

                    bool zhensushu = true;

                    for (int l = 2; l < mun; l++)
                    {
                        if (mun % l == 0)
                        {
                            zhensushu = false;
                            break;
                        }
                    }

                    if (zhensushu == true)
                    {
                        Console .Write ( i + " ");
                    }
                }
            }

            
           
        }
    }
}

 

 

所有回复
发表回复
你还没有登录,请先 登录或 注册!