Generation

generate functionSat, 07 Jan 2023

how to generate sub-arrays from an array?

int a[] = {1, 2, 3, 4, 5}; int n = sizeof(a) / sizeof(int); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { cout << "{" << a[i] << "," << a[j] << "}"; } }

Questions about programming?Chat with your personal AI assistant