Example #1
0
        private void BtnFindNearPrime_Click(object sender, EventArgs e)
        {
            this.LastExec_IsPrime = false;

            IntTools.Normalize(this.IsPrimeInputValue);
            string str = this.IsPrimeInputValue.Text;

            if (IntTools.IsULongString(str) == false)
            {
                MessageBox.Show(
                    "0 ~ " + ulong.MaxValue + " の整数を入力して下さい。",
                    "判定できません",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );

                this.PostExec_IsPrime();
                return;
            }
            this.NennotameMkPrimeDat();

            WorkDir workDir = new WorkDir();
            string  outFile = workDir.MakePath();

            this.ProcMan.Start(Gnd.I.Prime64File, "//MOLP " + StringTools.OUT_PFX + " //O \"" + outFile + "\" " + this.CmdPartOptUMRTM() + "/LH " + str);

            using (BusyDlg f = new BusyDlg())
            {
                f.SetInterval(delegate
                {
                    return(this.ProcMan.IsEnd() == false);
                });

                f.ShowDialog();
            }
            string[] lines = File.ReadAllLines(outFile);
            lines = StringTools.Prime64StdoutFilter(lines);
            string str_l = lines[0];
            string str_h = lines[1];

            if (str_l == "0")
            {
                str_l = "(なし)";
            }

            if (str_h == "0")
            {
                str_h = Gnd.I.PRIME_MIN_OVER_UL;
            }

            this.IsPrimeOutput.Text = "入力値:\r\n" + str + "\r\n入力値より小さい最大の素数:\r\n" + str_l + "\r\n入力値より大きい最小の素数:\r\n" + str_h;
            //this.IsPrimeOutput.Text = "n=\r\n" + str + "\r\nnより小さい最大の素数=\r\n" + str_l + "\r\nnより大きい最小の素数=\r\n" + str_h;
            //this.IsPrimeOutput.Text = str + "\r\n" + str_l + "\r\n" + str_h + "\r\n\r\n# 上から「入力値, 入力値より小さい最大の素数, 入力値より大きい最小の素数」です。";
            //this.IsPrimeOutput.Text = str_l + "\r\n" + str_h + "\r\n\r\n# 上から「 " + str + " より小さい最大の素数」「 " + str + " より大きい最小の素数」です。素数が見つからない場合は 0 を表示します。";

            workDir.Destroy();
            workDir = null;

            this.PostExec_IsPrime();
        }
Example #2
0
        private void BtnIsPrime_Click(object sender, EventArgs e)
        {
            this.LastExec_IsPrime = true;

            IntTools.Normalize(this.IsPrimeInputValue);
            string str = this.IsPrimeInputValue.Text;

            if (IntTools.IsULongString(str) == false)
            {
                MessageBox.Show(
                    "0 ~ " + ulong.MaxValue + " の整数を入力して下さい。",
                    "判定できません",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );

                this.PostExec_IsPrime();
                return;
            }
            this.NennotameMkPrimeDat();

            WorkDir workDir = new WorkDir();
            string  outFile = workDir.MakePath();

            this.ProcMan.Start(Gnd.I.Prime64File, "//MOLP " + StringTools.OUT_PFX + " //O \"" + outFile + "\" " + this.CmdPartOptUMRTM() + "/P " + str);

            using (BusyDlg f = new BusyDlg())
            {
                f.SetInterval(delegate
                {
                    return(this.ProcMan.IsEnd() == false);
                });

                f.ShowDialog();
            }
            string[] lines = File.ReadAllLines(outFile);
            lines = StringTools.Prime64StdoutFilter(lines);
            string ans = lines[0];

            if (ans == "IS_PRIME")
            {
                this.IsPrimeOutput.Text = str + "\r\nこの値は 素数 です。";
            }
            else if (ans == "IS_NOT_PRIME")
            {
                this.IsPrimeOutput.Text = str + "\r\nこの値は 素数 ではありません。2未満の整数又は合成数です。";
            }
            else
            {
                this.IsPrimeOutput.Text = str + "\r\n(エラー)";
            }
            workDir.Destroy();
            workDir = null;

            this.PostExec_IsPrime();
        }
Example #3
0
        private void BtnFactorize_Click(object sender, EventArgs e)
        {
            IntTools.Normalize(this.FactorizeInputValue);
            string str = this.FactorizeInputValue.Text;

            if (IntTools.IsULongString(str) == false || ulong.Parse(str) < 1)
            {
                MessageBox.Show(
                    "1 ~ " + ulong.MaxValue + " の整数を入力して下さい。",
                    "素因数分解できません",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );

                this.PostExec_Factorize();
                return;
            }
            this.NennotameMkPrimeDat();

            WorkDir workDir = new WorkDir();
            string  outFile = workDir.MakePath();

            this.ProcMan.Start(Gnd.I.Prime64File, "//MOLP " + StringTools.OUT_PFX + " //O \"" + outFile + "\" " + this.CmdPartOptUMRTM() + "/F " + str);

            using (BusyDlg f = new BusyDlg())
            {
                f.SetInterval(delegate
                {
                    return(this.ProcMan.IsEnd() == false);
                });

                f.ShowDialog();
            }
            string[] lines = File.ReadAllLines(outFile);
            lines = StringTools.Prime64StdoutFilter(lines);

            if (this.CheckFactorizeBekijou.Checked)
            {
                lines = this.ToBekijou(lines);
            }

            if (this.Chk改行しない.Checked)
            {
                this.FactorizeOutput.Text = str + " = " + string.Join(" * ", lines);
            }
            else
            {
                this.FactorizeOutput.Text = str + " の 素因数 は ...\r\n" + string.Join("\r\n", lines);
            }

            workDir.Destroy();
            workDir = null;

            this.PostExec_Factorize();
        }