All pastes #2067183 Raw Edit

Something

public cpp v1 · immutable
#2067183 ·published 2011-05-23 00:12 UTC
rendered paste body
#include <fstream>#include <iostream>#include <iomanip>#include <iostream>   using namespace std;#include <vector>int min_position(vector<string>& 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<string>& 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<string> 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<to; j++) {		if (bibleWords[j].empty()) {			to++;			cout << " Debug2: " << j << endl;		}		else {			cout << bibleWords[j].substr(0,5) << "hello" << endl;			cout << " Debug2: " << j << endl;			cout << "j " << j << endl;			cout << bibleWords[j] << endl;			cout << endl;		}	}		return 0;}