using System.Linq; //В начале файла
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int M = 0;
int N = 0;
int[,] Numbers;
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e) // создание матрицы
{
dataGridView1.Columns.Clear();
dataGridView1.Rows.Clear();
dataGridView1.AllowUserToAddRows = true;
M = int.Parse(M_input.Text);
N = int.Parse(N_input.Text);
Numbers = new int[0, 0];
Numbers = new int[N, M];
for (int i = 0; i < M; i++)
{
dataGridView1.Columns.Add("", "");
}
for (int i = 0; i < N; i++)
{
dataGridView1.Rows.Add("", "");
}
dataGridView1.AllowUserToAddRows = false;
}
//должна создавать вторую и выводить элементы массива( как я понял в виде строки)
private void button2_Click(object sender, EventArgs e)
{
int n = dataGridView1.RowCount;
int m = dataGridView1.ColumnCount;
double[,] mas = new double[n, m];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
{
mas[i, j] = double.Parse(dataGridView1.Rows[i].Cells[j].Value.ToString());
}
var result = Enumerable.Range(0, n).SelectMany(row => Enumerable.Range(0, m).Select(col => (row, col))).Where(x => Enumerable.Range(0, x.col).Sum(y => mas[x.row, y]) > Enumerable.Range(0, x.row).Sum(y => mas[y, x.col])).Select((elem, index => (elem: $"({x.row}, {x.col})", index));
dataGridView2.RowCount = 1;
dataGridView2.ColumnCount = result.Count();
result.Select(x => dataGridView2.Rows[0].Cells[x.index].Value = x.elem);
}
private void label1_Click(object sender, EventArgs e)
{
}
private void LUM1_Click(object sender, EventArgs e)
{
}
private void LUM2_Click(object sender, EventArgs e)
{
}
private void LUM3_Click(object sender, EventArgs e)
{
}
private void Matrix_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void M_input_TextChanged(object sender, EventArgs e)
{
}
private void N_input_TextChanged(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void Matrix2_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
}
}