VİZE 1 SORU 2016



int[] sayı = {3,4,5,7,2,1,0,5,7,6,1,4,8,9,2,3};
int[,] çoklu_array = new int[4, 4];//yeni array tanımlanıyor
int sayaç = 0;
private void button1_Click(object sender, EventArgs e)//MATRİS OLUŞTURMA
{
listBox2.Items.Clear();
//ARRAY OLUŞTURMA 4*4 SEKLİNDE
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
çoklu_array[i, j] = sayı[sayaç];
sayaç++;
}
}
//LİSTBOX A YAZDIRMA
for (int i = 0; i < 4; i++)
{
string satır = çoklu_array[i, 0].ToString();
for (int j = 1; j < 4; j++)
{
satır = satır + " " + çoklu_array[i, j].ToString();
}
listBox2.Items.Add(satır);
}
}
int[] satır_toplamı = new int[4];
int[] sutun_toplamı = new int[4];
int satır_top = 0;
int sutun_top = 0;
private void button2_Click(object sender, EventArgs e) //kontrol etme
{
listBox2.Items.Clear();
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
satır_top += çoklu_array[i, j];
}
satır_toplamı[i] = satır_top;
satır_top = 0;
}
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
sutun_top += çoklu_array[j, i];
}
sutun_toplamı[i] = sutun_top;
sutun_top = 0;
}
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
if (satır_toplamı[i]==sutun_toplamı[j])
{
listBox2.Items.Add((i+1) + " satır " + (j+1) + " sutune eşittir");
}
}
}
}