#include #include #include #include using namespace std; #include int min_position(vector& a, int from, int to) { int min_pos = from; int i; for (i = from + 1; i <= to; i++) if (a[i].length() < a[min_pos].length() ) min_pos = i; return min_pos; } void selection_sort(vector& a) { //a.size() int next; // The next position to be set to the minimum for (next = 0; next < 100 - 1; next++) { // Find the position of the minimum int min_pos = min_position(a, next, a.size() - 1); if (min_pos != next) swap(a[min_pos], a[next]); } } int main() { fstream Bible; string line; vector bibleWords; Bible.open ("bible.txt", fstream::in | fstream::out); if ( !Bible.is_open() ) { cout << "File could not be opened!" << endl; return(1); } int i =0; //for (int i=0; i<9; i++) { while(Bible.good()) { for (int p=0; p<100; p++) { getline (Bible,line,'.'); bibleWords.push_back(line); } } cout << "Done reading in Bible." << endl; cout << endl; Bible.close(); selection_sort(bibleWords); for (int k=bibleWords.size()-1; k>bibleWords.size()-11; k--) { cout << "k " << k << endl; cout << bibleWords[k] << endl; cout << endl; } int to = 10; for (int j=0; j