Hello people, I've got a 2-d array, the first row has a string in each position, the second has a number in each position returned by a function that run on the strings.I run the mutatedstring function, run the matchmutated and put the values into the array, offspring times. Then I need to find the minimum number, and return the corresponding string. Could I use the min function for one row? How do I do this?

string mutated_chooser(string origmutated,string orisentance int offspringnumber)

int array [2][offspringnumber]
for (int t=0; t=offspringnumber-1;t++){
		string newmutated = mutatedstring(origmutated);
		newmutated = array [0][t];
		int matchmutated = match(orisentance,newmutated);
		matchmutated = [t][0];
		// I need to find the minimum matchmutated in the array and return it's corresponding string

Thanks for the help!

5 Years
Discussion Span
Last Post by hamby

Could you not scan the numbers in a loop find the minimum and store the position in a variable then output the string in that position?


How would I scan only one row of the array, while still keeping the strings that it corresponds to usable?
This is what I've done so far:

string mutated_chooser(string origmutated,string orisentance int offspringnumber){
	int array [2][offspringnumber];
	int min;
		for (int t=0; t=offspringnumber-1;t++){
			string newmutated=mutatedstring(origmutated);
			newmutated= array [0][t];
			int matchmutated= match(orisentance,newmutated);
	int min = array[1][j];
		for (j=0; j=offspingnumber; j++)
			if (array[1][j] < min) 
			{min = a[1][j];} // set the smallest value of the arra
	//now i'm usure how to get the string back from the minimum matchnumber

if you create a variable say posvar
line 16

{min = array[1][j];posvar=j;}



Edited by frogboy77: n/a


There's an error coming up saying that "c++ does not support variable size arrays", is there an easy way out of this? Or do I have to use something like vectors (not too sure how to use them)?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.