for-Schleife in die Bedingung der while-Schleife
Hallo!
Ich möchte eine while Schleife erstellen, bei der in der while-Bedingung eine for-Schleife steht.
Ich habe mal ein kleines Beispielprogramm geschrieben. Mir ist bewusst, dass es sich hierbei auch um eine Endlosschleife handelt (bzw. handeln würde, sie funktioniert ja nicht).
Code:
#include<iostream>
using namespace std;
int main()
{
int array1[10][10];
int array2[10][10];
// Nullsetzen von array1
for(int i=0; i<=9; i++)
{
for(int j=0; j<=9; j++)
{
array1[i][j] = 0;
}
}
// Nullsetzen von array2
for(int i=0; i<=9; i++)
{
for(int j=0; j<=9; j++)
{
array2[i][j] = 0;
}
}
while (
for(int i=0; i<=9; i++)
{
for(int j=0; j<=9; j++)
{
array1[i][j] == array2[i][j];
}
}
)
{
cout << "Arrays sind identisch!" << endl;
return 0;
}
Das Problem ist, dass ich (wenn ich richtig informiert bin) Arrays nicht "im ganzen" miteinander vergleichen kann, sondern immer alles Schrittweise ausführen muss. Daher die for-Schleife.
Ich bin gespannt auch eure Lösungen!
Gruß Max