#include #include const int MAX_LENGTH = 35; typedef char string[MAX_LENGTH]; int swapCount = 0; string lines[10]; void Swap(string& X, string& Y) { string temp; strcpy(temp, X); strcpy(X, Y); strcpy(Y, temp); swapCount++; } void BubbleSort(string A[], int N) { bool Sorted = false; for (int Pass=1; (Pass 0 ) { Swap(A[Index], A[NextIndex]); Sorted = false; } } } } void main() { int index = 0; int line = 0; ifstream InFile("otherSorts.txt"); while ( InFile.peek() != EOF ) { InFile.getline(lines[line++], MAX_LENGTH); } InFile.close(); BubbleSort(lines, line++); ofstream OutFile("6.txt"); for (int i=0; i<10; i++) { OutFile << lines[i] << "\n"; } OutFile << "\nSwap Count = " << swapCount; OutFile.close(); }