Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void lineSwap(int arr[][3], int dim1, int dim2, int line1, int line2);
- int main() {
- int mas[3][3] = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
- lineSwap(mas, 3, 3, 0, 2);
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) printf("%d ", mas[i][j]);
- printf("\n");
- }
- return 0;
- }
- void lineSwap(int arr[][3], int dim1, int dim2, int line1, int line2) {
- for (int i = 0; i < dim2; i++) {
- int tmp = arr[line1][i];
- arr[line1][i] = arr[line2][i];
- arr[line2][i] = tmp;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement