Question: Fix the errors in the following C++ progtam so that it compiles in putty terminal. #include #include //#include #include #include using namespace std; using std::string;

Fix the errors in the following C++ progtam so that it compiles in putty terminal.

#include #include //#include #include #include using namespace std; using std::string; #define CROSS 0.7 #define MUTATION 0.001 #define POPS 100 #define CHROM_LNT 300 #define GENE_LNT 4 #define ALLOW_GEN 400 #define RAND (float)rand()/(RAND_MAX+1) struct chromType { string bit; float fitties; chromType(): bit(""), fitties(0.0f){}; chromType(string bts, float ftns): bit(bts), fitties(ftns){} }; void dispGeneSym(int values); string getRand(int lnt); int bin2Dec(string bit); float assFit(string bit, int tarVal); void dispChrom(string bit); void dispGeneSym(int values); int parsingBit(string bit, int* buff); string Roulette(int totFit, chromType* polulat); void Mutate(string &bit); void Crossover(string &off1, string &off2); int main() { srand((int)time(NULL)); while (true) { chromType polulat[POPS]; int targets; int uu; cout << " Input a target number: "; cin >> targets; cout << endl << endl; for (uu=0; uu ALLOW_GEN) { cout << "No solutions found this run!"; isFound = true; } } cout << " "; } return 0; } string getRand(int lnt) { string bit; for (int uu=0; uu 0.5f) bit += "1"; else bit += "0"; } return bit; } int bin2Dec(string bit) { int values = 0; int addValues = 1; for (int uu = bit.size(); uu > 0; uu--) { if (bit.at(uu-1) == '1') values += addValues; addValues *= 2; } return values; } int parsingBit(string bit, int* buff) { int cBuffer = 0; bool bOps = true; int genes = 0; for(int uu=0; uu< 13) ) continue; else { bOps= false; buff[cBuffer++] = genes; continue; } } else { if (genes > 9) continue; else { bOps = true; buff[cBuffer++] = genes; continue; } } } for (int uu=0;uu= slicing) return polulat[uu].bit; } return ""; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!