Advertisement
Maksud3

Lab6(KSanya)

May 19th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define N 5
  4.  
  5. void PrintM(int M[N][N]);
  6.  
  7. int main(void)
  8. {
  9.     int M[5][5] =
  10.     {
  11.         {1, 2, 3 ,4 ,5 },
  12.         { 1, 2, 3 ,4 ,5 },
  13.         { 1, 2, 3 ,4 ,5 },
  14.         { 1, 2, 3 ,4 ,5 },
  15.         { 1, 2, 3 ,4 ,5 }
  16.     };
  17.     int temp = 0;
  18.  
  19.     PrintM(M);
  20.     printf("\n");
  21.  
  22.     for (int i = 0; i < N; i++)
  23.     {
  24.         for (int j = 0; j < N-1; j++)
  25.         {
  26.             temp = M[i][j];
  27.             M[i][j] = M[i][j + 1];
  28.             M[i][j + 1] = temp;
  29.         }
  30.     }
  31.  
  32.     PrintM(M);
  33.  
  34. }
  35.  
  36. void PrintM(int M[N][N])
  37. {
  38.     for (int i = 0; i < N; i++)
  39.     {
  40.         for (int j = 0; j < N; j++)
  41.         {
  42.             printf("%2.d", M[i][j]);
  43.         }
  44.         printf("\n");
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement