C# :: Aufgabe #7 :: Lösung #6
15 Lösungen
#7
Übung mehrdimensionales Datenfeld welches aus zufälligen Inhalten besteht darstellen
Anfänger - C#
von Gustl
- 30.07.2012 um 23:37 Uhr
#6
von thareck (430 Punkte)
- 14.03.2015 um 21:53 Uhr
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 _07MehrdimensionalesDatenfeld
{
public partial class Form1 : Form
{
public Form1()
{
Random random = new Random();
int[, ,] IntArray3D = new int[6, 3, 4];
InitializeComponent();
for (int x = 0; x < IntArray3D.GetLength(0); x++)
{
for (int y = 0; y < IntArray3D.GetLength(1); y++)
{
label1.Text += "( ";
for (int i = 0; i < IntArray3D.GetLength(2); i++)
{
IntArray3D[x, y, i] = random.Next(20, 30);
label1.Text += IntArray3D[x, y, i].ToString() + " ";
}
label1.Text += ") ";
}
label1.Text += "\n";
}
int minValue = (from int i in IntArray3D select i).Min();
label2.Text += "Minimum: " + minValue + ", an Position: \n";
for (int x = 0; x < IntArray3D.GetLength(0); x++)
for (int y = 0; y < IntArray3D.GetLength(1); y++)
for (int i = 0; i < IntArray3D.GetLength(2); i++)
if (IntArray3D[x, y, i] == minValue)
label2.Text += "Zeile " + x + ". Gruppe " + y + ". Element " + i + "\n";
}
}
}
Kommentare:
Für diese Lösung gibt es noch keinen Kommentar
Seite 1 von 0
1
