Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- private double[,] CreateArray(int m, int n)
- {
- double[,] drr = new double[m, n];
- for (int i = 0; i < m; i++)
- {
- for (int j = 0; j < n; j++)
- {
- drr[i, j] = i * j - j / 42;
- }
- } return drr;
- }
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- int m;
- int n;
- private void button1_Click(object sender, EventArgs e)
- {
- if (!int.TryParse(textBox1.Text, out m) || m < 1)
- {
- MessageBox.Show("Ошибка!!", "Некорректный ввод", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- textBox1.Focus();
- return;
- }
- if (!int.TryParse(textBox2.Text, out n) || n < 1)
- {
- MessageBox.Show("Ошибка!!", "Некорректный ввод", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- textBox1.Focus();
- return;
- }
- dataGridView1.ColumnCount = n;
- dataGridView1.RowCount = m;
- double[,] drr = CreateArray(m, n);
- for (int i = 0; i < m; i++)
- {
- for (int j = 0; j < n; j++)
- {
- dataGridView1[j, i].Value = drr[i, j].ToString("F3");
- }
- }
- }
- private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement