-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHiddenDigits.cpp
More file actions
57 lines (50 loc) · 841 Bytes
/
Copy pathHiddenDigits.cpp
File metadata and controls
57 lines (50 loc) · 841 Bytes
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
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
map<char, int> values;
void createMap()
{
for (int i = 97; i < 107; ++i)
{
values[char(i)] = i - 97;
}
for (int i = 48; i < 58; ++i)
{
values[char(i)] = i - 48;
}
}
void printHiddenDigits(string& str)
{
int count = 0;
for (int i = 0; i < str.length(); ++i)
{
if (islower(str[i]) || isdigit(str[i])){
auto it = values.find(str[i]);
if (it != values.end())
{
cout << it->second;
++count;
}
}
}
if (count == 0)
cout << "NONE" << endl;
else
cout << endl;
}
int main(int argc, const char * argv[])
{
createMap();
ifstream ifs(argv[1]);
string token;
while (getline(ifs, token))
{
printHiddenDigits(token);
}
system("pause");
}