-
Notifications
You must be signed in to change notification settings - Fork 0
/
Source.cpp
58 lines (52 loc) · 1.22 KB
/
Source.cpp
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
48
49
50
51
52
53
54
55
56
57
58
#include "Autocomplete.h"
#include <iostream>
#include <fstream>
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
using namespace std;
int main()
{
Autocomplete * autocomp = new Autocomplete();
std::cout << "Enter file name"<<std::endl;
string line;
std::cin >> line;
ifstream myfile(line);
if (myfile.is_open())
{
while (getline(myfile, line))
{
//std::cout << line<<std::endl;
autocomp->instert(line);
}
myfile.close();
}
do{
std::cout << " Enter | quit | suggest | insert | change " << std::endl;
std::cin >> line;
if (line=="suggest")
{
std::cout << "Enter prefix to suggest a word" << std::endl;
std::cin >> line;
autocomp->suggest(line);
std::cout << "---------------------------------------------------"<<std::endl;
}
else if (line == "insert")
{
std::cout << "Enter word to insert in dictonary" << std::endl;
std::cin >> line;
autocomp->instert(line);
}
else if(line=="change")
{
std::cout << "Enter number to change k." << std::endl;
int k;
std::cin >> k;
autocomp->change(k);
}
} while (line != "quit");
delete autocomp;
myfile.clear();
myfile.close();
return 0;
}