Untitled

mail@pastecode.io avatar
unknown
plain_text
20 days ago
711 B
2
Indexable
Never
#include <stdio.h>

void revRows(unsigned int n, unsigned int m, int tab[n][m]) {
    for (unsigned int i = 0; i < n; ++i) {
        for (unsigned int j = 0; j < m / 2; ++j) {
            int temp = tab[i][j];
            tab[i][j] = tab[i][m - j - 1];
            tab[i][m - j - 1] = temp;
        }
    }
}


int main() {
    unsigned int n = 3;
    unsigned int m = 3;
    int tab[3][3] = {
            {1, 2, 3},
            {4, 5, 6},
            {7, 8, 9}
    };

    revRows(n, m, tab);

    for (unsigned int i = 0; i < n; ++i) {
        for (unsigned int j = 0; j < m; ++j) {
            printf("%d ", tab[i][j]);
        }
        printf("\n");
    }


    return 0;
}
Leave a Comment