Just use a for loop to iterate over values of x:
for (x = 9; x > 0; x--) {
    for (y = 0; y < 9; y++) {
        if (3 * pow (x, 2) + 4* pow(y, 2) == 271) {
            cout << "x: " << x << endl << "y: " << y << endl;
        }
    }
}
2
solved C++ programming more efficient way to do