Advertisement
Nishat_Samrin

They are snakes

Oct 14th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int i, j, r, c;
  6. int max,mr,mc;
  7. int x[10][10];
  8.  
  9. scanf("%d %d", &r, &c);
  10. if(r>c)
  11. max=r;
  12. else
  13. max=c;
  14.  
  15.  
  16. for (i = 0; i < max; i++)
  17. {
  18. for (j = 0; j < c; j++)
  19. {
  20. scanf("%d", &x[i][j]);
  21. }
  22. }
  23.  
  24.  
  25. for (int i = 0; i < max; i++) {
  26. if (i%2 == 0)
  27. for (int j = 0; j < max; j++)
  28. printf("%d ", x[i][j]);
  29. else
  30. for (int j = c - 1; j >= 0; j--)
  31. printf("%d ", x[i][j]);
  32. }
  33.  
  34.  
  35.  
  36.  
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement