我有这些 for 循环。
// output all possible combinations
for ( int i1 = 0; i1 <= 2; i1++ )
{
for ( int i2 = 0; i2 <= 2; i2++ )
{
for ( int i3 = 0; i3 <= 2; i3++ )
{
for ( int i4 = 0; i4 <= 2; i4++ )
{
for ( int i5 = 0; i5 <= 2; i5++ )
{
for ( int i6 = 0; i6 <= 2; i6++ )
{
for ( int i7 = 0; i7 <= 2; i7++ )
{
//output created words to outFile
outFile
<< phoneLetters[n[0]][i1]<< phoneLetters[n[1]][i2]
<< phoneLetters[n[2]][i3]<< phoneLetters[n[3]][i4]
<< phoneLetters[n[4]][i5]<< phoneLetters[n[5]][i6]
<< phoneLetters[n[6]][i7]
<< " ";
if ( ++count % 9 == 0 ) // form rows
outFile << std::endl;
}
}
}
}
}
}
}
它看起来很糟糕,但我太新手了,不知道从哪里开始浓缩它们。
有人可以给我一两个指针,以便我可以使这段代码更整洁吗?