diff options
Diffstat (limited to 'Bachelor/Prog2/Prakt4/aufg1/main.cpp')
| -rw-r--r-- | Bachelor/Prog2/Prakt4/aufg1/main.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Bachelor/Prog2/Prakt4/aufg1/main.cpp b/Bachelor/Prog2/Prakt4/aufg1/main.cpp new file mode 100644 index 0000000..79581e3 --- /dev/null +++ b/Bachelor/Prog2/Prakt4/aufg1/main.cpp @@ -0,0 +1,47 @@ +// Tree with string objects +// Author: Sven Eisenhauer +// Date: 05.06.05 + +#include <iostream> +using std::cout; +using std::cerr; +using std::cin; +using std::endl; + +#include <fstream> +using std::ofstream; +using std::ifstream; +using std::ios; + +#include <string> +using std::string; + +#include <cstdlib> +#include <new> + +#include "Tree.h" + +int main() +{ + int wordsInFile=0; + Tree< string > wordTree; + string word; + + ifstream inFile( "max.txt", ios::in ); + + if( !inFile ) { + cerr << "Input-Datei konnte nicht geoeffnet werden." << endl; + exit( 1 ); + } + + while( inFile >> word) { + wordTree.insertNode( *( new string( word ) ) ); + wordsInFile++; + } + + wordTree.inOrderTraversal(); + cout << "Words in input file: "<< wordsInFile << endl; + cout << "Different words: " << wordTree.gettreeElementCount() << endl; + + return 0; +} |
