Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void mujHAD(int **pole, int sloupceMax) {
- int i, minIndexRadku = 0, minIndexSloupce = 0, radkyMax = sloupceMax;
- /*
- [0][0] 0 [0][1] 1 [0][2] 2 [0][3] 3
- [1][0] 4 [1][1] 5 [1][2] 6 [1][3] 7
- [2][0] 8 [2][1] 9 [2][2] 10 [2][3] 11
- [3][0] 12 [3][1] 13 [3][2] 14 [3][3] 15
- */
- while (minIndexRadku < radkyMax && minIndexSloupce < sloupceMax) {
- //vypsání 1. sloupce
- for (i = minIndexSloupce; i < sloupceMax; i++) {
- printf("%d ", pole[i][minIndexSloupce]);
- }
- minIndexSloupce++;
- //vypsání 4. řádku
- for (i = minIndexSloupce; i < radkyMax; i++) {
- printf("%d ",pole[sloupceMax-1][i]);
- }
- sloupceMax--;
- //vypsání 4. sloupce
- if(minIndexSloupce<=sloupceMax){
- for (i = sloupceMax-1; i>=minIndexRadku ; i--) {
- printf("%d ",pole[i][sloupceMax]);
- }
- radkyMax--;
- }
- //vypsání 1.řádku
- if(minIndexRadku<radkyMax){
- for (i = sloupceMax-1; i >minIndexRadku ; i--) {
- printf("%d ",pole[minIndexRadku][i]);
- }
- minIndexRadku++;
- }
- }
- }
- void vypisHAD(int **pole, int n) {
- int i, k = 0, l = 0, m = n;
- /* k - starting row index
- m - ending row index
- l - starting column index
- n - ending column index
- i - iterator
- */
- while (k < m && l < n) {
- /* Print the first row from the remaining rows */
- for (i = l; i < n; ++i) {
- printf("%d ", pole[k][i]);
- }
- k++;
- /* Print the last column from the remaining columns */
- for (i = k; i < m; ++i) {
- printf("%d ", pole[i][n - 1]);
- }
- n--;
- /* Print the last row from the remaining rows */
- if (k < m) {
- for (i = n - 1; i >= l; --i) {
- printf("%d ", pole[m - 1][i]);
- }
- m--;
- }
- /* Print the first column from the remaining columns */
- if (l < n) {
- for (i = m - 1; i >= k; --i) {
- printf("%d ", pole[i][l]);
- }
- l++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement