#include #include "gene.h" FILE *DataFile; extern char *DataFileName; extern gene_type *GeneTable; extern int PopulationSize; htoi(c) char c; { if ('0' <= c && c <= '9') return c - '0'; else if ('A' <= c && c <= 'F') return c - 'A' + 10; else if ('a' <= c && c <= 'f') return c - 'a' + 10; } void b_load() { int i, j; char buf[1300]; fseek(DataFile, 0L, 0); for (i = 0; i < PopulationSize && fgets(buf,1300,DataFile); i++) for (j = 0; j < GeneLen; j ++) GeneTable[i].gene[j] = (htoi(buf[j*3]) << 4) + htoi(buf[j*3+1]); } void b_save() { int i, j; fseek(DataFile, 0L, 0); for (i = 0; i < PopulationSize; i ++) for (j = 0; j < GeneLen; j ++) fprintf(DataFile,"%x%c",GeneTable[i].gene[j], ((j