You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
170 lines
5.9 KiB
C#
170 lines
5.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Übungen_LF6_WinFormanwendung
|
|
{
|
|
public partial class ArrayÜbung : Form
|
|
{
|
|
Random zufall = new Random();
|
|
bool[,] parität = new bool[5, 5];
|
|
int countTrue = 0;
|
|
|
|
public ArrayÜbung()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void button_ende_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void listBox_RandomArray_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void button_startZufall_Click(object sender, EventArgs e)
|
|
{
|
|
listBox_Zeile1.Items.Clear();
|
|
listBox_Zeile2.Items.Clear();
|
|
listBox_Zeile3.Items.Clear();
|
|
listBox_Zeile4.Items.Clear();
|
|
listBox_Zeile5.Items.Clear();
|
|
|
|
for (int ersteDim = 0; ersteDim < parität.GetLength(1)-1; ersteDim++)
|
|
{
|
|
for (int zweiteDim = 0; zweiteDim < parität.GetLength(0)-1; zweiteDim++)
|
|
{
|
|
if(zweiteDim != 5 && ersteDim != 5 )
|
|
parität[ersteDim,zweiteDim] = Convert.ToBoolean(zufall.Next(0,2));
|
|
switch (ersteDim)
|
|
{
|
|
case 0: listBox_Zeile1.Items.Add(parität[ersteDim,zweiteDim]);break;
|
|
case 1: listBox_Zeile2.Items.Add(parität[ersteDim, zweiteDim]); break;
|
|
case 2: listBox_Zeile3.Items.Add(parität[ersteDim, zweiteDim]); break;
|
|
case 3: listBox_Zeile4.Items.Add(parität[ersteDim, zweiteDim]); break;
|
|
case 4: listBox_Zeile5.Items.Add(parität[ersteDim, zweiteDim]); break;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void listBox_Zeile1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void button_horiPari_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
for (int zweiteDim = 0; zweiteDim < parität.GetLength(1) - 1; zweiteDim++)
|
|
{
|
|
countTrue = 0;
|
|
for (int ersteDim = 0; ersteDim < parität.GetLength(0) - 1; ersteDim++)
|
|
{
|
|
if (parität[ersteDim, zweiteDim] == true)
|
|
countTrue++;
|
|
|
|
}
|
|
switch (zweiteDim)
|
|
{
|
|
case 0:
|
|
if (countTrue % 2 > 0)
|
|
listBox_Zeile1.Items.Add(false);
|
|
else
|
|
listBox_Zeile1.Items.Add(true);
|
|
break;
|
|
case 1:
|
|
if (countTrue % 2 > 0)
|
|
listBox_Zeile2.Items.Add(false);
|
|
else
|
|
listBox_Zeile2.Items.Add(true);
|
|
break;
|
|
case 2:
|
|
if (countTrue % 2 > 0)
|
|
listBox_Zeile3.Items.Add(false);
|
|
else
|
|
listBox_Zeile3.Items.Add(true);
|
|
break;
|
|
case 3:
|
|
if (countTrue % 2 > 0)
|
|
listBox_Zeile4.Items.Add(false);
|
|
else
|
|
listBox_Zeile4.Items.Add(true);
|
|
break;
|
|
case 4:
|
|
if (countTrue % 2 > 0)
|
|
listBox_Zeile5.Items.Add(false);
|
|
else
|
|
listBox_Zeile5.Items.Add(true);
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void button_vertiPari_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
for (int ersteDim = 0; ersteDim < parität.GetLength(1) - 1; ersteDim++)
|
|
{
|
|
countTrue = 0;
|
|
for (int zweiteDim = 0; zweiteDim < parität.GetLength(0) - 1; zweiteDim++)
|
|
{
|
|
if (parität[ersteDim, zweiteDim] == true)
|
|
countTrue++;
|
|
|
|
}
|
|
switch (ersteDim)
|
|
{
|
|
case 0:
|
|
if (countTrue % 2 > 0)
|
|
listBox_Zeile1.Items.Add(false);
|
|
else
|
|
listBox_Zeile1.Items.Add(true);
|
|
break;
|
|
case 1:
|
|
if (countTrue % 2 > 0)
|
|
listBox_Zeile2.Items.Add(false);
|
|
else
|
|
listBox_Zeile2.Items.Add(true);
|
|
break;
|
|
case 2:
|
|
if (countTrue % 2 > 0)
|
|
listBox_Zeile3.Items.Add(false);
|
|
else
|
|
listBox_Zeile3.Items.Add(true);
|
|
break;
|
|
case 3:
|
|
if (countTrue % 2 > 0)
|
|
listBox_Zeile4.Items.Add(false);
|
|
else
|
|
listBox_Zeile4.Items.Add(true);
|
|
break;
|
|
case 4:
|
|
if (countTrue % 2 > 0)
|
|
listBox_Zeile5.Items.Add(false);
|
|
else
|
|
listBox_Zeile5.Items.Add(true);
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|