Как объединить 3 цикла for в 1? ⇐ C++

Программы на C++. Форум разработчиков
Anonymous
Как объединить 3 цикла for в 1?

Сообщение Anonymous »


#include
using namespace std;

int main()
{

int count = 1;

// Declaring 3D array
int array1[3][4][5];

// Initialize 3D array using loop
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 4; j++) {
for (int k = 0; k < 5; k++) {
array1[j][k] = count;
count++;
}
}
}

// Printing the element of 3D array
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 4; j++) {
for (int k = 0; k < 5; k++) {
cout

Подробнее здесь: https://stackoverflow.com/questions/790 ... ops-into-1

Вернуться в «C++»