-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem.cpp
More file actions
55 lines (51 loc) · 1.02 KB
/
Copy pathproblem.cpp
File metadata and controls
55 lines (51 loc) · 1.02 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
#include "problem.h"
#include <iostream>
#include <iomanip>
void Problem::log(std::string label, bool answ) const
{
std::cout << "-- " << label << std::setw(3) << rating
<< std::setw(4) << points
<< " dataset " << dataset
<< " " << problem_id
<< " priority = " << priority;
if (answ) std::cout << "\n" << answer << "\n";
std::cout << "\n";
}
void Problem::answer2skeleton()
{
const unsigned N = answer.length();
char c {};
skeleton.clear();
skeleton.reserve(N);
bool inws = true, isws;
for (unsigned i=0; i<N; i++)
{
c = std::tolower(answer[i]);
switch (c) {
case ' ':
case '(':
case ')':
case '<':
case '>':
case '+':
case '-':
case '=':
case ';':
case ',':
case '\f':
case '\n':
case '\r':
case '\t':
case '\v':
c = ' ';
isws = true;
break;
default:
isws = false;
break;
}
if (inws && isws) continue;
skeleton.push_back(c);
inws = isws;
}
}