Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {            
            Complex comp = new Complex();

            _rp1 = comp.GetRealPart(realTB1.Text);
            _rp2 = comp.GetRealPart(realTB2.Text);
            _ip1 = comp.GetImaginaryPart(imagTB1.Text);
            _ip2 = comp.GetImaginaryPart(imagTB2.Text);
            
            if (comboBox1.SelectedIndex == 0)
            {
                _resofreal = comp.Sum(_rp1, _rp2);
                _resofimag = comp.Sum(_ip1, _ip2);
                _result = "а="+_resofreal+"+"+_resofimag+"i";
            }
            else
                if (comboBox1.SelectedIndex == 1)
                {
                    _resofreal = comp.Raznost(_rp1, _rp2);
                    _resofimag = comp.Raznost(_ip1, _ip2);
                    _result = "а=" + _resofreal + "+" + _resofimag + "i";
                }
                else
                    if (comboBox1.SelectedIndex == 2)
                    {                        
                        _result = comp.umnozhenie(_rp1, _rp2, _ip1, _ip2);
                    }
                    else
                        if (comboBox1.SelectedIndex == 3)
                        {
                            _result = comp.delenie(_rp1, _rp2, _ip1, _ip2);
                        }
                        else
                            if (comboBox1.SelectedIndex == 4)
                            {
                                _result = comp.sravnenie(_rp1, _rp2, _ip1, _ip2);
                            }
            MessageBox.Show("1е комплексное число: а="+realTB1.Text+"+"+imagTB1.Text+"i\n2е комплексное число: а="
                            +realTB2.Text+"+"+imagTB2.Text+"i\nРезультат операции: "+ _result);
        }