1
0
Files
OAiP-Presnyakov_Ilya-Labora…/MatrixCompareWindow.xaml.cs
Debug_pro 43d7845cf1 finally
2026-02-12 01:01:44 +03:00

63 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Lab
{
/// <summary>
/// Interaction logic for MatrixCompareWindow.xaml
/// </summary>
public partial class MatrixCompareWindow : Window
{
private DataTable _a = Matrices.CreateMatrix(11, 11, "A");
private DataTable _b = Matrices.CreateMatrixInts(11, 11, "B");
private void ClickBack(object sender, RoutedEventArgs e) => Close();
private void ClickGen(object sender, RoutedEventArgs e)
{
Matrices.RandomFill(_a, -25, 25);
MatrixInfoText.Text = "Матрица A сгенерирована.";
}
private void ClickBuild(object sender, RoutedEventArgs e)
{
var a = Matrices.ToArray(_a);
var b = new int[11, 11];
for (int row = 0; row < 11; row++)
{
int diag = a[row, row];
for (int col = 0; col < 11; col++)
{
b[row, col] = a[row, col] > diag ? 1 : 0;
}
}
_b = Matrices.FromArray(b, "B");
GridB.ItemsSource = _b.DefaultView;
MatrixInfoText.Text = "Матрица B построена.";
}
public MatrixCompareWindow()
{
InitializeComponent();
GridA.ItemsSource = _a.DefaultView;
GridB.ItemsSource = _b.DefaultView;
}
}
}