task1.c 796 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define SIZE 7
  4. int main(void)
  5. {
  6. int num, matrix[SIZE * SIZE], x, y, x1, y1;
  7. if (scanf("%d", &num) <= 0)
  8. exit(1);
  9. for (int i = 0; i < num * num; i++)
  10. if (scanf("%d", matrix + i) <= 0)
  11. exit(1);
  12. x = 0; y = num - 1;
  13. while (x != num || y != 0) {
  14. x1 = x;
  15. y1 = y;
  16. if (y > 0) {
  17. while (y1 != num) {
  18. printf("%d ", *(matrix + num * y1 + x1));
  19. y1 += 1;
  20. x1 += 1;
  21. }
  22. y--;
  23. } else {
  24. while (x1 != num) {
  25. printf("%d ", *(matrix + num * y1 + x1));
  26. y1 += 1;
  27. x1 += 1;
  28. }
  29. x++;
  30. }
  31. }
  32. putchar('\n');
  33. return 0;
  34. }