This is the Expert Bloopers' take on overcomplicating, where we take a simple concept and turn it into a convoluted mess of complexity.
Here's a list of our latest and greatest in overcomplicating:
int main() {
// Create an array of 10 random numbers
int arr[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
// Iterate over the array 5 times
for(int i = 0; i < 5; i++) {
for(int j = 0; j < 5; j++) {
if(i == j) {
arr[i] += 1;
}
}
}
// Return the array
return arr;
}
And here's the code for the previous example, just in case you wanted to see it again:
int main() {
// Create an array of 5 random numbers
int arr[5] = [1, 2, 3, 4, 5];
// Iterate over the array 3 times
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 5; j++) {
if(j % 2 == 0) {
arr[j] += 1;
}
}
}
// Return the array
return arr;
}
Inventing New Problems for No Reason is a classic.