Advertisement
Guest User

super

a guest
Nov 14th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.31 KB | None | 0 0
  1.  
  2. void mujHAD(int **pole, int sloupceMax) {
  3.     int i, minIndexRadku = 0, minIndexSloupce = 0, radkyMax = sloupceMax;
  4.     /*
  5.         [0][0] 0        [0][1] 1        [0][2] 2        [0][3] 3
  6.         [1][0] 4        [1][1] 5        [1][2] 6        [1][3] 7
  7.         [2][0] 8        [2][1] 9        [2][2] 10       [2][3] 11
  8.         [3][0] 12       [3][1] 13       [3][2] 14       [3][3] 15
  9.         */
  10.     while (minIndexRadku < radkyMax && minIndexSloupce < sloupceMax) {
  11.         //vypsání 1. sloupce
  12.         for (i = minIndexSloupce; i < sloupceMax; i++) {
  13.             printf("%d ", pole[i][minIndexSloupce]);
  14.         }
  15.         minIndexSloupce++;
  16.         //vypsání 4. řádku
  17.         for (i = minIndexSloupce; i < radkyMax; i++) {
  18.             printf("%d ",pole[sloupceMax-1][i]);
  19.         }
  20.         sloupceMax--;
  21.         //vypsání 4. sloupce
  22.         if(minIndexSloupce<=sloupceMax){
  23.             for (i = sloupceMax-1;  i>=minIndexRadku ; i--) {
  24.                 printf("%d ",pole[i][sloupceMax]);
  25.             }
  26.             radkyMax--;
  27.         }
  28.         //vypsání 1.řádku
  29.         if(minIndexRadku<radkyMax){
  30.             for (i = sloupceMax-1; i >minIndexRadku ; i--) {
  31.                 printf("%d ",pole[minIndexRadku][i]);
  32.             }
  33.             minIndexRadku++;
  34.         }
  35.     }
  36. }
  37.  
  38. void vypisHAD(int **pole, int n) {
  39.     int i, k = 0, l = 0, m = n;
  40.  
  41.  
  42.     /*  k - starting row index
  43.         m - ending row index
  44.         l - starting column index
  45.         n - ending column index
  46.         i - iterator
  47.     */
  48.  
  49.     while (k < m && l < n) {
  50.         /* Print the first row from the remaining rows */
  51.         for (i = l; i < n; ++i) {
  52.             printf("%d ", pole[k][i]);
  53.         }
  54.         k++;
  55.  
  56.         /* Print the last column from the remaining columns */
  57.         for (i = k; i < m; ++i) {
  58.             printf("%d ", pole[i][n - 1]);
  59.         }
  60.         n--;
  61.  
  62.         /* Print the last row from the remaining rows */
  63.         if (k < m) {
  64.             for (i = n - 1; i >= l; --i) {
  65.                 printf("%d ", pole[m - 1][i]);
  66.             }
  67.             m--;
  68.         }
  69.  
  70.         /* Print the first column from the remaining columns */
  71.         if (l < n) {
  72.             for (i = m - 1; i >= k; --i) {
  73.                 printf("%d ", pole[i][l]);
  74.             }
  75.             l++;
  76.         }
  77.     }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement