Advertisement
OneBumBot

Form2

Sep 26th, 2022
683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.68 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace Lab1
  5. {
  6.     public partial class Form2 : Form
  7.     {
  8.         public Form2()
  9.         {
  10.             InitializeComponent();
  11.         }
  12.  
  13.         private void label7_Click(object sender, EventArgs e)
  14.         {
  15.  
  16.         }
  17.  
  18.         private void label4_Click(object sender, EventArgs e)
  19.         {
  20.  
  21.         }
  22.  
  23.         private void button1_Click(object sender, EventArgs e)
  24.         {
  25.             if(textBox1.Text == "")
  26.             {
  27.                 MessageBox.Show("Нужно ввести число");
  28.                 return;
  29.             }
  30.             uint number;
  31.             if ((textBox1.Text)[0] == '0')
  32.             {
  33.                 MessageBox.Show("Число не может начинаться с нуля");
  34.                 return;
  35.             }
  36.  
  37.             if (UInt32.TryParse(textBox1.Text, out number))
  38.             {
  39.                 try
  40.                 {
  41.                     textBox2.Text = (textBox1.Text)[1].ToString();
  42.                 }
  43.                 catch(Exception)
  44.                 {
  45.                     MessageBox.Show("Данное число не имеет второй цифры");
  46.                 }
  47.             }
  48.             else if(textBox1.Text != "")
  49.             {
  50.                 MessageBox.Show("Введён неверный формат числа");
  51.             }
  52.            
  53.  
  54.         }
  55.  
  56.         private void button2_Click(object sender, EventArgs e)
  57.         {
  58.             uint number;
  59.            
  60.             if (textBox1.Text == "")
  61.             {
  62.                 MessageBox.Show("Нужно ввести число");
  63.                 return;
  64.             }
  65.             if (UInt32.TryParse(textBox1.Text, out number) || (textBox1.Text)[0] == '0')
  66.             {
  67.             }
  68.             else if (textBox1.Text != "")
  69.             {
  70.                 MessageBox.Show("Введён неверный формат числа");
  71.                 return;
  72.             }
  73.  
  74.            
  75.             if (textBox3.Text == "")
  76.             {
  77.                 MessageBox.Show("Нужно ввести число А");
  78.                 return;
  79.             }
  80.             uint A;
  81.             if (!UInt32.TryParse(textBox3.Text, out A) || (textBox3.Text)[0]=='0')
  82.             {
  83.                 MessageBox.Show("Неверный формат числа A");
  84.                 return;
  85.             }
  86.             else if(A == 0)
  87.             {
  88.                 MessageBox.Show("Число A должно быть отличным от 0");
  89.                 return;
  90.             }
  91.             if (textBox4.Text == "")
  92.             {
  93.                 MessageBox.Show("Нужно ввести число B");
  94.                 return;
  95.             }
  96.             uint B;
  97.             if (!UInt32.TryParse(textBox4.Text, out B) || (textBox4.Text)[0] == '0')
  98.             {
  99.                 MessageBox.Show("Неверный формат числа B");
  100.                 return;
  101.             }
  102.             else if (B  == 0)
  103.             {
  104.                 MessageBox.Show("Число B должно быть отличным от 0");
  105.                 return;
  106.             }
  107.             if (textBox5.Text == "")
  108.             {
  109.                 MessageBox.Show("Нужно ввести число C");
  110.                 return ;
  111.             }
  112.             uint C;
  113.             if (!UInt32.TryParse(textBox5.Text, out C) || (textBox5.Text)[0] == '0')
  114.             {
  115.                 MessageBox.Show("Неверный формат числа C");
  116.                 return;
  117.             }
  118.             else if (C == 0)
  119.             {
  120.                 MessageBox.Show("Число C должно быть отличным от 0");
  121.                 return;
  122.             }
  123.  
  124.  
  125.            
  126.                if (A == 0 || B == 0 || C == 0)
  127.                 {
  128.                     MessageBox.Show("Деление на 0 неосуществимо");
  129.                     return;
  130.                 }
  131.                if (number % A == 0 && number % B == 0 && number % C == 0)
  132.                 {
  133.                     textBox6.Text = "Делится";
  134.                 }
  135.                else
  136.                 {
  137.                     textBox6.Text = "Не делится";
  138.                 }
  139.            
  140.         }
  141.  
  142.         private void button3_Click(object sender, EventArgs e)
  143.         {
  144.             for(int i = 10; i < 100; i++)
  145.             {
  146.                 if((i * 2)%10 == 8 && (i*3)%10 == 4)
  147.                 {
  148.                     textBox7.Text += i.ToString();
  149.                 }
  150.             }
  151.            
  152.             if (textBox7.Text == "")
  153.             {
  154.                 textBox7.Text = "Таких чисел не существует";
  155.             }
  156.         }
  157.     }
  158. }
  159.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement