Когда я запускаю его, я получаю сообщение об ошибке, как показано на прикрепленном снимке экрана.
< img alt="ОШИБКА" src="https://i.sstatic.net/twlE4vyf.png" />
Код: Выделить всё
public bool CompareString(string lName1, string lName2, string fName1, string fName2)
{
// While there are letters in the last name
for (int i = 0; i < lName1.Length && i < lName2.Length; i++)
{
// If letter of first string is after letter of pivot string
if (lName1[i] > lName2[i])
return false;
else if (lName1[i] < lName2[i])
return true;
// If we get here, last names are the same
else if (i == lName1.Length - 1 || i == lName2.Length - 1)
{
// While there are letters in the first name
for (int j = 0; j < fName1.Length && j < fName2.Length; j++)
{
// If letter of first string is less than letter of pivot string
if (fName1[j] < fName2[j])
{
return false;
}
}
} // End first name compare
} // End name compare
// Pivot string is first alphabetically
return true;
} // End CompareString
// PURPOSE: Fills array with data from file
// PRE:
// POST: Array filled with data from file
public void SortList(int leftInd, int rightInd)
{
int l = leftInd; // initialized with 0
int r = rightInd; // initialized with numDivers - 1
// DiverRec pivot = diverList[leftInd]; // set to first value
DiverRec temp;
// Assign last names to left, right, & pivot
string lLast = LastName(diverList[l].name);
string rLast = LastName(diverList[r].name);
string pLast = LastName(diverList[l].name);
// Assign first names to left, right, & pivot
string lFirst = FirstName(diverList[l].name);
string rFirst = FirstName(diverList[r].name);
string pFirst = FirstName(diverList[l].name);
// Compare left & right strings with pivot
while (l
Подробнее здесь: [url]https://stackoverflow.com/questions/79202569/endless-quicksort-recursive-function-academic-assignment[/url]
Мобильная версия