Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <time.h>
  4. #define N 9
  5.  
  6.  
  7. int main()
  8. {
  9. srand(time(NULL));
  10. int temp = 0;
  11. int a[N][N] = { 0 };
  12. printf("Matrix:\n");
  13. int k = 1;
  14. for (int i = 0; i < N; ++i)
  15. {
  16. for (int j = 0; j < N; ++j)
  17. {
  18. if (i < j && i + j < N - 1 || i > j && i + j > N - 1)
  19. {
  20. a[j][i] = k++;
  21. }
  22. }
  23. }
  24. for (int i = 0; i < N; ++i)
  25. {
  26. for (int j = 0; j < N; ++j)
  27. {
  28.  
  29. printf("%2d ", a[i][j]);
  30. }
  31. printf("\n");
  32. }
  33.  
  34.  
  35. system("pause");
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement