Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Lab1
- {
- public partial class Form2 : Form
- {
- public Form2()
- {
- InitializeComponent();
- }
- private void label7_Click(object sender, EventArgs e)
- {
- }
- private void label4_Click(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if(textBox1.Text == "")
- {
- MessageBox.Show("Нужно ввести число");
- return;
- }
- uint number;
- if ((textBox1.Text)[0] == '0')
- {
- MessageBox.Show("Число не может начинаться с нуля");
- return;
- }
- if (UInt32.TryParse(textBox1.Text, out number))
- {
- try
- {
- textBox2.Text = (textBox1.Text)[1].ToString();
- }
- catch(Exception)
- {
- MessageBox.Show("Данное число не имеет второй цифры");
- }
- }
- else if(textBox1.Text != "")
- {
- MessageBox.Show("Введён неверный формат числа");
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- uint number;
- if (textBox1.Text == "")
- {
- MessageBox.Show("Нужно ввести число");
- return;
- }
- if (UInt32.TryParse(textBox1.Text, out number) || (textBox1.Text)[0] == '0')
- {
- }
- else if (textBox1.Text != "")
- {
- MessageBox.Show("Введён неверный формат числа");
- return;
- }
- if (textBox3.Text == "")
- {
- MessageBox.Show("Нужно ввести число А");
- return;
- }
- uint A;
- if (!UInt32.TryParse(textBox3.Text, out A) || (textBox3.Text)[0]=='0')
- {
- MessageBox.Show("Неверный формат числа A");
- return;
- }
- else if(A == 0)
- {
- MessageBox.Show("Число A должно быть отличным от 0");
- return;
- }
- if (textBox4.Text == "")
- {
- MessageBox.Show("Нужно ввести число B");
- return;
- }
- uint B;
- if (!UInt32.TryParse(textBox4.Text, out B) || (textBox4.Text)[0] == '0')
- {
- MessageBox.Show("Неверный формат числа B");
- return;
- }
- else if (B == 0)
- {
- MessageBox.Show("Число B должно быть отличным от 0");
- return;
- }
- if (textBox5.Text == "")
- {
- MessageBox.Show("Нужно ввести число C");
- return ;
- }
- uint C;
- if (!UInt32.TryParse(textBox5.Text, out C) || (textBox5.Text)[0] == '0')
- {
- MessageBox.Show("Неверный формат числа C");
- return;
- }
- else if (C == 0)
- {
- MessageBox.Show("Число C должно быть отличным от 0");
- return;
- }
- if (A == 0 || B == 0 || C == 0)
- {
- MessageBox.Show("Деление на 0 неосуществимо");
- return;
- }
- if (number % A == 0 && number % B == 0 && number % C == 0)
- {
- textBox6.Text = "Делится";
- }
- else
- {
- textBox6.Text = "Не делится";
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- for(int i = 10; i < 100; i++)
- {
- if((i * 2)%10 == 8 && (i*3)%10 == 4)
- {
- textBox7.Text += i.ToString();
- }
- }
- if (textBox7.Text == "")
- {
- textBox7.Text = "Таких чисел не существует";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement