- 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
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
int minimal_array(int array[], int flag_array[] , int intro_run) {
int step;
int end = -1;
int Minimum = 8;
for(step = 0; step <= 7; ++step) {
if( array[step] <= Minimum && array[step] >= 1 && flag_array[step] == 1 ) {
Minimum = array[step];
end = step;
}
}
if( intro_run >= (chess * chess - 4) || intro_run <= (chess * chess - 2 ) ) {
for(step = 0; step <= 7; ++step) {
if( array[step] == 0 && flag_array[step] == 1 ) {
end = step;
}
}
}
return end;
}
int check_point( int row, int column, int bord[][chess] ) {
int p;
row >= 0 && row <= chess - 1 && column >= 0 && column <= chess -1 && bord[row][column] == 0 ? (p = 1 ) : (p = 0);
return p;
}
int cor_hor(int hor_out ) {
static int horizont[chess] = {2,1,-1,-2,-2,-1,1,2 };
return horizont[hor_out];
}
int cor_ver(int ver_out) {
static int verti[chess] = { -1, -2,-2,-1,1,2,2,1 };
return verti[ver_out];
}
int minimum_possible(int cur_Column,int cur_Row, int extro_board[][chess],int run) {
int check_point( int row, int column, int bord[][chess] ),
cor_hor(int in ),
cor_ver(int ni),
extro_stop = 0,
intro_board[chess][chess] = {0 },
extro_array[8] = {0 },
step_row[8] = {0 },
step_column[8] = {0 },
intro_array[8] = {0 },
extro_number_shift,
extro_shag = 0,
extro_Row ,
extro_Column ,
cycle_all= 0 ,
step = 0;
memcpy( intro_board ,extro_board, sizeof(intro_board ));
for( extro_number_shift = -1; extro_stop <= 8; ) {
extro_Row += cor_ver(extro_number_shift),extro_Column += cor_hor(extro_number_shift);
if(check_point( extro_Row ,extro_Column , intro_board ) == 1) {
intro_board[extro_Row][extro_Column] = ++extro_shag;
++extro_array[extro_number_shift];
step_row[extro_number_shift] = extro_Row ;
step_column[extro_number_shift] = extro_Column ;
} else {
++extro_stop;
}
extro_Column = cur_Column;
extro_Row = cur_Row;
++extro_number_shift ;
}
while(cycle_all <= 7) {
if(extro_array[cycle_all] == 1) {
memcpy( intro_board,extro_board,sizeof(intro_board ));
intro_board[cur_Row][cur_Column] = 1;
for( extro_stop = 0, extro_number_shift = -1 ; extro_stop != 8;) {
extro_Row += cor_ver(extro_number_shift) ,extro_Column += cor_hor(extro_number_shift );
if( check_point( extro_Row ,extro_Column , intro_board ) == 1) {
intro_board[extro_Row][extro_Column] = extro_shag++;
++intro_array[cycle_all];
} else {
extro_stop++;
}
extro_Row = step_row[cycle_all];
extro_Column = step_column[cycle_all] ;
++extro_number_shift;
}
}
++cycle_all;
}
return minimal_array(intro_array ,extro_array , run ) ;
}
bot 17.04.2016 23:31 # +2
yet_another_one_shit 11.05.2018 14:48 # 0