summaryrefslogtreecommitdiffstats
path: root/Bachelor/Prog2/Prakt4/aufg1/main.cpp
blob: 79581e37b9e0c0a439c675f30b0077d5141bc9dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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;
}