#include <iostream>
#include <utility>

int main() {
    int arr[3][3] = {
        { 1, 2, 3 },
        { 4, 5, 6 },
        { 7, 8, 9 }
    };
    int target = 5;
    
    try {
        
        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++)
                if (arr[i][j] == target) throw std::make_pair(i, j);
        
    } catch (std::pair<int, int> index) {
        std::cout << target << " found at (" << index.first << ',' << index.second << ").\n";
    }
}
By Anonymous, 2025-01-05 06:08:52