-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeadbottom.c
33 lines (27 loc) · 1.14 KB
/
deadbottom.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/***********************************************************************************/
/* Program: deadbottom.c
By: Brad Duthie
Description: Brings positive values to matrix top
Compile: gcc deadbottom.c -ansi -Wall -pedantic */
/***********************************************************************************/
#include<stdio.h>
void deadbottom(double **ID, int rows, int cols, int M){
int j, k, h;
double dtemp;
/**********************************************************************/
/* Below shifts all the dead, and effectively dead (too old to breed) */
/* individuals from the population to the bottom of the table */
/**********************************************************************/
for(j=rows-2; j>=0; j--){
for(k=0; k<=j; k++){
if( (ID[k][4]<0 || ID[k][4]>M) &&
(ID[k+1][4]>=0 && ID[k+1][4] <= M) ){
for(h=0; h<cols; h++){
dtemp = ID[k][h];
ID[k][h] = ID[k+1][h];
ID[k+1][h] = dtemp;
}
}
}
}
}