Exemple #1
0
        public void SimplePascal()
        {
            string str = "";

            str += "\t\n\n Упрощённый Паскаль: \n";
            str += $"\nn = {n}, d = {d}\n";
            str += "n = 10^t*a + b0\n";
            str += "n/d <=> (r_t*a + b)/d\n\n";
            str += "r рассчитываются в предыдущем методе\n";
            int am = Mult.CountOfNumber(n);

            int[] r = new int[n];
            for (int i = 0; i < am; i++)
            {
                r[i] = (int)Pow(10, i) % d;
                str += $"r_{i} = {r[i]}\n";
            }
            str += $"{n} / {d} <=> ";
            List <int> divs     = new List <int>();
            List <int> rs       = new List <int>();
            int        curr_div = n;


            while (curr_div != 0)
            {
                int s = Mult.CountOfNumber(curr_div);
                str += "( ";
                int new_div = 0;

                int i;
                if (s > 1)
                {
                    i = s / 2;
                }
                else
                {
                    i = s - 1;
                }
                i        = s - 1;
                new_div += r[i] * (curr_div / (int)Pow(10, i)) + curr_div % (int)Pow(10, i);
                str     += $"{r[i]} * {curr_div / (int)Pow(10, i)} + {curr_div % (int)Pow(10, i)} ) / {d} <=> {new_div} / {d}";
                divs.Add(curr_div);

                curr_div = new_div;
                if (divs.Contains(curr_div) && rs.Contains(r[i]))
                {
                    break;
                }
                else
                {
                    str += " <=>";
                    rs.Add(r[i]);
                }
            }
            rtb.Text += str;
        }
Exemple #2
0
        public void Pascal()
        {
            string str = "";

            str += "\t\n\n Паскаль: \n";
            str += $"\nn = {n}, d = {d}\n";
            str += "n = 10^s*n_s + 10^s-1*n_s-1 + ... + 10*n_1 + n_0\n";
            str += "10 = a_1*d +r_1\n10^2 = a_2*d +r_2\n10^s = a_s*d +r_s\n";
            str += "n/d <=> (r_s*n_s + r_s-1*n_s-1 + ... + r_1*n_1 + r_0)/d\n\n";
            int am = Mult.CountOfNumber(n);

            int[] r = new int[n];
            for (int i = 0; i < am; i++)
            {
                r[i] = (int)Pow(10, i) % d;
                str += $"r_{i} = {r[i]}\n";
            }
            str += $"{n} / {d} <=> ";
            List <int> divs     = new List <int>();
            int        curr_div = n;


            while (curr_div != 0)
            {
                int s = Mult.CountOfNumber(curr_div);
                str += "( ";
                int new_div = 0;

                for (int i = s - 1; i > 0; i--)
                {
                    new_div += r[i] * ((curr_div / (int)Pow(10, i)) % 10);
                    str     += $"{r[i]} * {((curr_div / (int)Pow(10, i)) % 10)} + ";
                }
                new_div += r[0] * ((curr_div / (int)Pow(10, 0)) % 10);
                str     += $"{r[0]} * {(curr_div / (int)Pow(10, 0)) % 10} ) / {d} <=> {new_div} / {d}";

                divs.Add(curr_div);
                curr_div = new_div;
                if (divs.Contains(curr_div))
                {
                    break;
                }
                else
                {
                    str += " <=>";
                }
            }
            rtb.Text += str;
        }
Exemple #3
0
        public void Pascal()
        {
            string str = "";

            str += "\t\n\n Паскаль: \n";
            str += $"\nn = {n}, d = {d}\n";
            str += "(r_s*n_s + r_s-1*n_s-1 + ... + r_1*n_1 + r_0)\n\n";
            int am = Mult.CountOfNumber(n);
            int j  = 0;

            int[] r = new int[n];
            for (int i = 0; i < am; i++)
            {
                r[i] = (int)Pow(10, i) % d;
                str += $"r_{i} = {r[i]}\n";
            }
            List <int> divs     = new List <int>();
            int        curr_div = n;


            while (curr_div != 0)
            {
                int s = Mult.CountOfNumber(curr_div);
                str += $" {++j}) ( ";
                int new_div = 0;

                for (int i = s - 1; i > 0; i--)
                {
                    new_div += r[i] * ((curr_div / (int)Pow(10, i)) % 10);
                    str     += $"{r[i]} * {((curr_div / (int)Pow(10, i)) % 10)} + ";
                }
                new_div += r[0] * ((curr_div / (int)Pow(10, 0)) % 10);
                str     += $"{r[0]} * {(curr_div / (int)Pow(10, 0)) % 10} ) = {new_div} \n";

                divs.Add(curr_div);
                curr_div = new_div;
                if (divs.Contains(curr_div))
                {
                    break;
                }
                else
                {
                    str += "";
                }
            }
            rtb.Text += str;
            rtb.Text += $"Ответ: {n}/{d} <=> {curr_div}/{d}\n";
        }
Exemple #4
0
 public Form1()
 {
     InitializeComponent();
     Z1 = new Mult(richTextBox2);
     Z2 = new Matrix(richTextBox3);
 }