Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Разложение
- {
- public partial class Form1 : Form
- {
- public static int len = 0;
- public static int lenf = 0;
- public Form1()
- {
- InitializeComponent();
- len = listBox1.Height;
- lenf = this.Height;
- textBox1.Click += new EventHandler(tb_eventClick);
- }
- private void tb_eventClick(object snd, EventArgs a)
- {
- textBox1.Text = "";
- }
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- listBox1.Items.Clear();
- listBox1.Height = len;
- this.Height = len + 10;
- decimal a = Convert.ToDecimal(textBox1.Text);
- decimal[] ard = new decimal[1000];
- decimal[] dl = new decimal[1000];
- ard[0] = a;
- for (decimal i = 2, ct = 1, pt = 0; ; )
- {
- if (a % i == 0)
- {
- ard[checked((int)ct++)] = a /= i;
- dl[checked((int)pt++)] = i;
- }
- else i++;
- if (a == 1)
- {
- for (decimal g = 0; g < ct - 1; g++)
- listBox1.Items.Add(ard[checked((int)g)].ToString() + "," + dl[checked((int)g)].ToString());
- listBox1.Items.Add(a.ToString());
- break;
- }
- }
- listBox1.Height += 13 * listBox1.Items.Count;
- this.Height += listBox1.Height + 40;
- }
- catch (OverflowException)
- {
- MessageBox.Show(this, "Слишком большое число", "Ошибка", MessageBoxButtons.OK);
- }
- catch (Exception)
- {
- this.Height = lenf;
- MessageBox.Show(this, "...", "Ошибка", MessageBoxButtons.OK);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment