pair<int, int> findNonDivisiblePair(const std::vector<int>& vec) { for (size_t i = 0; i < vec.size(); ++i) { for (size_t j = i + 1; j < vec.size(); ++j) { if (vec[i] % vec[j] != 0 && vec[j] % vec[i] != 0) { return std::make_pair(vec[i], vec[j]); } } } // If no pair is found, return a pair of -1, -1 or handle as required return std::make_pair(-1, -1); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter