- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#define chess 18
int minimum_possible(int cur_Column,int cur_Row, int extro_board[][chess], int run ),
check_point( int row, int column, int bord[][chess] ),
cor_hor(int hor_out ),
cor_ver(int ver_out);
int main(void) {
int step = 1 ,
y,x,
moveNumber = 1,
currentColumn,
currentRow,
board[chess][chess] = {0 } , p = 1;
while( p ) {
printf("enter the coordinates of the knight y x: ");
scanf("%d %d",¤tColumn , ¤tRow );
if (currentColumn < 0 || (currentColumn > (chess - 1) ) || (currentRow < 0 || (currentRow > (chess - 1)) ) ) {
puts("correct the coordinates of the knight from 0 to 11 for x and y");
} else {
p = 0;
}
}
while( moveNumber != -1 ) {
board[currentRow][ currentColumn] = step++;
moveNumber = minimum_possible(currentColumn,currentRow ,board , step ) ;
currentRow += cor_ver(moveNumber);
currentColumn += cor_hor(moveNumber);
}
for(x = 0; x <= chess - 1; x++) {
puts(" ");
for(y = 0 ; y <= chess - 1; y++)
printf("%3d ", board[x][y]);
}
return 0;
}
Комментарии (0) RSS
Добавить комментарий