FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
GoogleHashCodeTestRound/Parser.cpp at master · Loniowsky/GoogleHashCodeTestRound · GitHub
This repository was archived by the owner on Apr 2, 2021. It is now read-only.
Loniowsky
/
GoogleHashCodeTestRound
Public archive
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
GoogleHashCodeTestRound
/
Parser.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
75 lines (56 loc) · 1.46 KB
Breadcrumbs
GoogleHashCodeTestRound
/
Parser.cpp
Copy path
File metadata and controls
75 lines (56 loc) · 1.46 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
"
Parser.h
"
#
include
"
PrintVector.h
"
unsigned
rows =
0
;
unsigned
columns =
0
;
unsigned
min =
0
;
unsigned
max =
0
;
#
include
<
fstream
>
#
include
<
iostream
>
#
include
<
cstdlib
>
#
include
<
string
>
std::vector<std::vector<
bool
>>*
Parser
()
{
std::ifstream
inputFile
(
"
medium.in
"
);
if
(!inputFile.
is_open
())
{
std::cerr<<
"
Could not open file. Exiting
"
<<std::endl;
exit
(-
1
);
}
std::string line;
getline
(inputFile, line);
rows =
atoi
(line.
c_str
());
line = line.
substr
(line.
find
(
"
"
,
1
));
columns =
atoi
(line.
c_str
());
line = line.
substr
(line.
find
(
"
"
,
1
));
min =
atoi
(line.
c_str
());
line = line.
substr
(line.
find
(
"
"
,
1
));
max =
atoi
(line.
c_str
());
std::cout<<
"
Rows:
"
<<rows<<std::endl;
std::cout<<
"
Columns:
"
<<columns<<std::endl;
std::cout<<
"
Min:
"
<<min<<std::endl;
std::cout<<
"
Max:
"
<<max<<std::endl;
std::string pizzaRow;
auto
ptrToVector =
new
std::vector<std::vector<
bool
>>;
char
ingredient;
for
(
unsigned
i=
0
; i<columns; ++i)
{
ptrToVector->
emplace_back
();
}
for
(
unsigned
i=
0
; i<rows; ++i)
{
getline
(inputFile, pizzaRow);
for
(
unsigned
j=
0
; j<columns; ++j)
{
ingredient = pizzaRow.
at
(
0
);
pizzaRow.
erase
(
0
,
1
);
//
std::cout<<ingredient;
if
(ingredient==
'
T
'
)
ptrToVector->
at
(j).
push_back
(
false
);
else
ptrToVector->
at
(j).
push_back
(
true
);
}
//
std::cout<<std::endl;
}
//
PrintVector(*ptrToVector, rows, columns);
return
ptrToVector;
}
Back
|
FazBrowse Home
|
New Git URL