ANTICHAT Forum
HOME FORUMS MEMBERS RECENT POSTS LOG IN  
Баннер 1   Баннер 2
НОВЫЕ ТОРГОВАЯ НОВОСТИ
loading...
Скрыть
Вернуться   ANTICHAT > ПРОГРАММИРОВАНИЕ > С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby
   
 
 
Опции темы Поиск в этой теме Опции просмотра

Решение уравнений методом Крамера [c#]
  #1  
Старый 17.10.2007, 10:47
[x26]VOLAND
Постоянный
Регистрация: 07.06.2006
Сообщений: 556
С нами: 10487846

Репутация: 2702


По умолчанию Решение уравнений методом Крамера [c#]

http://www.voland-lab.com/files/other/KramerMax.exe
Может кому надо....
Сорс:
PHP код:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace 
KramerMax
{
    public 
partial class Form1 : Form
    
{
        public 
Form1()
        {
          
InitializeComponent();
        }

        
float def(float[,] a) //находим определитель
        
{
            
float def;
            
def = a[1,1]*a[2,2]*a[3,3] + a[1,2]*a[2,3]*a[3,1] + a[2,1]*a[3,2]*a[1,3] - a[1,3]*a[2,2]*a[3,1] - a[1,2]*a[2,1]*a[3,3] - a[1,1]*a[2,3]*a[3,2];
            return 
def;
        }
        
        private 
void button1_Click(object sender, EventArgs e)
        {
            
xt.Text = "";
            
yt.Text = "";
            
zt.Text = "";
            
tssl.Text = "";

            if (
a11.Text == "" || a12.Text == "" || a13.Text == "" || a21.Text == "" || a22.Text == "" || a23.Text == "" || a31.Text == "" || a32.Text == "" || a33.Text == "")
            {
                
tssl.Text = "Введены не все коэффициенты";
            }
            else
            {
                
float[,] a = new float[4, 4];
                
a[1, 1] = float.Parse(a11.Text);
                
a[1, 2] = float.Parse(a12.Text);
                
a[1, 3] = float.Parse(a13.Text);
                
a[2, 1] = float.Parse(a21.Text);
                
a[2, 2] = float.Parse(a22.Text);
                
a[2, 3] = float.Parse(a23.Text);
                
a[3, 1] = float.Parse(a31.Text);
                
a[3, 2] = float.Parse(a32.Text);
                
a[3, 3] = float.Parse(a33.Text);
                
deftxt.Text = def(a).ToString();
            }
        }

        private 
void button2_Click(object sender, EventArgs e)
        {
            
tssl.Text = "";

            if (
a11.Text == "" || a12.Text == "" || a13.Text == "" || a21.Text == "" || a22.Text == "" || a23.Text == "" || a31.Text == "" || a32.Text == "" || a33.Text == "" || b1.Text == "" || b2.Text == "" || b3.Text == "")
            {
                
tssl.Text = "Введены не все элементы уравнения";
            }
            else
            {
                
float[,] A = new float[4, 4];
                
A[1, 1] = float.Parse(a11.Text);
                
A[1, 2] = float.Parse(a12.Text);
                
A[1, 3] = float.Parse(a13.Text);
                
A[2, 1] = float.Parse(a21.Text);
                
A[2, 2] = float.Parse(a22.Text);
                
A[2, 3] = float.Parse(a23.Text);
                
A[3, 1] = float.Parse(a31.Text);
                
A[3, 2] = float.Parse(a32.Text);
                
A[3, 3] = float.Parse(a33.Text);
                
float D = def(A);
                
deftxt.Text = D.ToString();

                
float[,] a = new float[4, 4];
                
a[1, 1] = float.Parse(b1.Text);
                
a[1, 2] = float.Parse(a12.Text);
                
a[1, 3] = float.Parse(a13.Text);
                
a[2, 1] = float.Parse(b2.Text);
                
a[2, 2] = float.Parse(a22.Text);
                
a[2, 3] = float.Parse(a23.Text);
                
a[3, 1] = float.Parse(b3.Text);
                
a[3, 2] = float.Parse(a32.Text);
                
a[3, 3] = float.Parse(a33.Text);
                
float Dx = def(a);

                
float[,] b = new float[4, 4];
                
b[1, 1] = float.Parse(a11.Text);
                
b[1, 2] = float.Parse(b1.Text);
                
b[1, 3] = float.Parse(a13.Text);
                
b[2, 1] = float.Parse(a21.Text);
                
b[2, 2] = float.Parse(b2.Text);
                
b[2, 3] = float.Parse(a23.Text);
                
b[3, 1] = float.Parse(a31.Text);
                
b[3, 2] = float.Parse(b3.Text);
                
b[3, 3] = float.Parse(a33.Text);
                
float Dy = def(b);

                
float[,] c = new float[4, 4];
                
c[1, 1] = float.Parse(a11.Text);
                
c[1, 2] = float.Parse(a12.Text);
                
c[1, 3] = float.Parse(b1.Text);
                
c[2, 1] = float.Parse(a21.Text);
                
c[2, 2] = float.Parse(a22.Text);
                
c[2, 3] = float.Parse(b2.Text);
                
c[3, 1] = float.Parse(a31.Text);
                
c[3, 2] = float.Parse(a32.Text);
                
c[3, 3] = float.Parse(b3.Text);
                
float Dz = def(c);

                
float x, y, z;
                
x = Dx / D;
                
y = Dy / D;
                
z = Dz / D;

                
xt.Text = x.ToString();
                
yt.Text = y.ToString();
                
zt.Text = z.ToString();
            }
        }
    }
} 
 
Ответить с цитированием
 



Предыдущая тема Следующая тема

Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 


Быстрый переход




ANTICHAT ™ © 2001- Antichat Kft.