-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmain.cpp
More file actions
89 lines (65 loc) · 1.61 KB
/
Copy pathmain.cpp
File metadata and controls
89 lines (65 loc) · 1.61 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <string>
#include <fstream>
#include <iostream>
#include "stringset.h"
using namespace std;
void compute(void)
{
Stringset S;
string x, y;
ifstream wordfile("points.txt");
while (wordfile >> x >> y)
S.insert(x, y);
wordfile.close();
//S.print();
double smallest = S.compute();
cout << smallest << " is the smallest. \n";
//while (cin >> word) {
// cout << "Possible alternatives for word '" << word << "':\n";
// TBD: print out all words that differ by exactly one character...
//alternative = word;
// for (char &w:alternative) {
// for (const char &c:alphabet) {
// w = c;
// if (S.find(alternative) && alternative != word)
// cout << alternative << "\n";
// }
// alternative = word;
// }
//}
}
void test(void)
{
Stringset S;
string x, y, command;
while(cin >> command) {
if (command == "insert") {
cin >> x >> y;
if (S.find(x, y))
cout << "Error! (x,y) " << x << y << " already in structure!\n";
else
S.insert(x, y);
} else if (command == "find") {
cin >> x >> y;
if (S.find(x, y))
cout << "(x,y) " << x << y << " present.\n";
else
cout << "(x,y) " << x << y<< " absent.\n";
} else if (command == "print") {
cout << "Contents of structure:\n";
S.print();
} else if (command == "quit") {
break;
} else {
cout << "Error! Unknown command '" << command << "'!\n";
}
}
}
int main(void)
{
// string d = "0.98489102";
// cout << d << " " << stod(d)<< "\n";
// test();
compute();
return 0;
}