-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tools.cpp
83 lines (76 loc) · 1.58 KB
/
Tools.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
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
#include"Tools.h"
void clear(void *buffer, int value, size_t bufSize)
{
unsigned char *ptr = (unsigned char *)buffer;
for (size_t i = 0; i < bufSize; i++) {
ptr[i] = (unsigned char)value;
}
}
DL<string> splitString(const string& str)
{
DL<string> result;
string word;
for (char sym : str)
{
if (sym == ' ')
{
if (!word.empty())
{
result.LDPUSHT(word);
}
word = "";
}
else
{
word += sym;
}
}
if (!word.empty())
{
result.LDPUSHT(word);
}
return result;
}
string input()
{
string command;
cout << "<<";
char oldSym;
while (true)
{
char sym = getchar();
if (sym=='\n' || sym == '\\')
{
if (sym == '\n' && oldSym != '\\')
{
break;
}
oldSym = sym;
command+=' ';
continue;
}
oldSym = sym;
command += sym;
}
return command;
}
string PlusOne(string& num)
{
int len = num.size();
int countLoop = 0;
for (size_t i = len - 1; i >= 0; i--)
{
if (num[i] < '9')
{
num = num.substr(0, i) + char(num[i] + 1);
string countNull = "";
for (int j = 0; j < countLoop; j++)
{
countNull += '0';
}
num = num + countNull;
return num;
}
countLoop++;
}
}