Advertisement
thevals

Untitled

Oct 28th, 2021
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. void  lineSwap(int arr[][3], int dim1, int dim2, int line1, int line2);
  3.  
  4. int main() {
  5.     int mas[3][3] = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
  6.     lineSwap(mas, 3, 3, 0, 2);
  7.     for (int i = 0; i < 3; i++) {
  8.         for (int j = 0; j < 3; j++) printf("%d ", mas[i][j]);
  9.         printf("\n");
  10.     }
  11.     return 0;
  12. }
  13. void  lineSwap(int arr[][3], int dim1, int dim2, int line1, int line2) {
  14.     for (int i = 0; i < dim2; i++) {
  15.         int tmp = arr[line1][i];
  16.         arr[line1][i] = arr[line2][i];
  17.         arr[line2][i] = tmp;
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement