fork download
#include 
#include 

template
void sort_every_row(int (&a)[R][C])
{
    for(size_t r = 0; r < R; ++r)
        std::sort(a[r], a[r] + C);
}

template
void print_array(int (&a)[R][C])
{
    for(size_t r = 0; r < R; ++r)
    {
        for(size_t c = 0; c < C; ++c)
            std::cout << a[r][c] << ' ';
        std::cout << '\n';
    }
}


int main()
{
    int a1[2][4] = {{9, 4, 2, 1},
                    {3, 5, 6, 2}};

    sort_every_row(a1);
    print_array(a1);
}
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
1 2 4 9 
2 3 5 6