Code is not running pls find mistakes

#include
using namespace std;
void findTriplets(int arr[], int n, int target) {
// Sort the array
for (int i = 0; i < n - 1; ++i) {
for (int j = i + 1; j < n; ++j) {
if (arr[j] < arr[i]) {
int temp = arr[j];
arr[j] = arr[i];
arr[i] = temp;
}
}
}

// Loop to find triplets
for (int i = 0; i < n - 2; ++i) {
    // Skip duplicates
    if (i > 0 && arr[i] == arr[i - 1]) {
        continue;
    }

    for (int j = i + 1; j < n - 1; ++j) {
        // Skip duplicates
        if (j > i + 1 && arr[j] == arr[j - 1]) {
            continue;
        }

        for (int k = j + 1; k < n; ++k) {
            if (arr[i] + arr[j] + arr[k] == target) {
                cout << arr[i] << ", " << arr[j] << " and " << arr[k] << std::endl;
                break;
            }
        }
    }
}

}

int main() {
int n;
cin >> n;

int nums[n];
for (int i = 0; i < n; ++i) {
    cin >> nums[i];
}

int target;
cin >> target;

findTriplets(nums, n, target);

return 0;

}