From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- Bachelor/Prog2/Prakt4/aufg1/main.cpp | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Bachelor/Prog2/Prakt4/aufg1/main.cpp (limited to 'Bachelor/Prog2/Prakt4/aufg1/main.cpp') 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 +using std::cout; +using std::cerr; +using std::cin; +using std::endl; + +#include +using std::ofstream; +using std::ifstream; +using std::ios; + +#include +using std::string; + +#include +#include + +#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; +} -- cgit v1.2.3