Using System. Drawing. Drawing2D; namespace 1


Download 36.74 Kb.
Sana19.06.2023
Hajmi36.74 Kb.
#1615394


1.
using System.Drawing.Drawing2D;

namespace 1


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

private void button1_Click(object sender, EventArgs e)


{
Random random = new Random();
int n = int.Parse(textBox1.Text);
int m = int.Parse(textBox2.Text);

int[,] array = new int[n, m];


for (int i = 0; i < n; i++)


{
for (int j = 0; j < m; j++)
{
array[i, j] = random.Next(-10, 10);
}
}

int musbat = 0;


int manfiy = 0;
bool isdone = false;
for (int i = 0; i < array.GetLength(0); i++)
{
for (int j = 0; j < array.GetLength(1); j++)
{
if (array[j, i] > 0)
musbat++;
if (array[j, i] < 0)
manfiy++;
}
if (manfiy == musbat)
{
label3.Text = i + " ustundagi musbat va manfiy elementlar soni teng";
isdone = true;
}
musbat = 0;
manfiy = 0;
}

int numRows = array.GetLength(0);


int numCols = array.GetLength(1);

dataGridView1.ColumnCount = numCols;


for (int row = 0; row < numRows; row++)


{
dataGridView1.Rows.Add();

for (int col = 0; col < numCols; col++)


{
dataGridView1.Rows[row].Cells[col].Value = array[row, col];
}
}

if (!isdone)


label4.Text = "massivning hechqaysi ustundagi musbat va manfiy elementlari teng emas";
}

private void Form1_Load(object sender, EventArgs e)


{

}
}
}




2.
namespace 2


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

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)


{

}


private void button1_Click(object sender, EventArgs e)
{

int n = int.Parse(textBox1.Text);


int[,] array = new int[n, n];


for (int i = 0; i < n; i++)


{
for (int j = i; j < n; j++)
{
array[i, j] = j + 1;
}
}
int numRows = array.GetLength(0);
int numCols = array.GetLength(1);

dataGridView1.ColumnCount = numCols;


for (int row = 0; row < numRows; row++)


{
dataGridView1.Rows.Add();

for (int col = 0; col < numCols; col++)


{
dataGridView1.Rows[row].Cells[col].Value = array[row, col];
}
}
}
}
}


Download 36.74 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling