Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dsprog
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Manuel Bucher
dsprog
Commits
3139f60c
Commit
3139f60c
authored
6 years ago
by
Manuel Bucher
Browse files
Options
Downloads
Patches
Plain Diff
finilized read_line
parent
aff0e3f9
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile
+2
-2
2 additions, 2 deletions
Makefile
loesung.c
+17
-21
17 additions, 21 deletions
loesung.c
with
19 additions
and
23 deletions
Makefile
+
2
−
2
View file @
3139f60c
all
:
loesung
WARNINGS
=
-Wall
-Werror
OPTIONAL
=
#
-Werror -Wpedantic
OPTIONAL
=
-Werror
-Wpedantic
DEBUG
=
-ggdb
-fno-omit-frame-pointer
OPTIMIZE
=
-O3
-std
=
c11
...
...
@@ -12,7 +12,7 @@ clean:
# Builder will call this to install the application before running.
install
:
#nothing
echo install
# Builder uses this target to run your application.
run
:
...
...
This diff is collapsed.
Click to expand it.
loesung.c
+
17
−
21
View file @
3139f60c
...
...
@@ -34,25 +34,19 @@ ReadResult read_line(Tile* p_tile){
if
(
c
==
EOF
)
{
return
RdEof
;
}
int
num
_number
s
=
0
;
int
cur
_number
=
0
;
bool
cur_whitespace
=
true
;
uint32_t
*
p_cur
;
// aktuell zu parsende Zahl
while
(
1
)
{
c
=
getchar
();
if
(
'0'
<=
c
&&
c
<=
'9'
)
{
if
(
cur_whitespace
)
{
num_numbers
++
;
if
(
cur_number
==
2
)
{
return
RdErrTooManyNumbers
;
}
p_cur
=
(
&
p_tile
->
x
)
+
cur_number
;
*
p_cur
=
0
;
cur_whitespace
=
false
;
}
uint32_t
*
p_cur
;
switch
(
num_numbers
)
{
case
1
:
p_cur
=
&
p_tile
->
x
;
break
;
case
2
:
p_cur
=
&
p_tile
->
y
;
break
;
default:
return
RdErrTooManyNumbers
;
cur_number
++
;
}
// 429496730 = 2^32 / 10, daher wenn `p_cur` groesser ist, wird ein
// overflow erzeugt
...
...
@@ -68,11 +62,11 @@ ReadResult read_line(Tile* p_tile){
}
(
*
p_cur
)
+=
digit
;
}
else
if
(
c
==
' '
)
{
if
(
cur_whitespace
==
tru
e
)
{
cur_whitespace
=
fals
e
;
if
(
cur_whitespace
==
fals
e
)
{
cur_whitespace
=
tru
e
;
}
}
else
if
(
c
==
'\n'
)
{
if
(
num
_number
s
==
2
)
{
if
(
cur
_number
==
2
)
{
return
RdOk
;
}
else
{
return
RdErrTooFewNumbers
;
...
...
@@ -80,6 +74,8 @@ ReadResult read_line(Tile* p_tile){
}
else
{
return
RdErrNonDigitCharacter
;
}
c
=
getchar
();
// get next character
}
return
RdOk
;
}
...
...
@@ -146,12 +142,12 @@ int main (int argc,
ReadResult
result
=
parse_input
(
&
f
);
switch
(
result
)
{
case
RdOk
:
printf
(
"Valider Input"
);
printf
(
"Anzahl: %d"
,
f
.
num_tiles
);
printf
(
"Range(%d, %d), (%d, %d)"
,
printf
(
"Valider Input
\n
"
);
printf
(
"Anzahl: %d
\n
"
,
f
.
num_tiles
);
printf
(
"Range(%d, %d), (%d, %d)
\n
"
,
f
.
t_min
.
x
,
f
.
t_min
.
y
,
f
.
t_max
.
x
,
f
.
t_max
.
y
);
printf
(
"Range x: %d, %d"
,
printf
(
"Range x: %d, %d
\n
"
,
f
.
t_max
.
x
-
f
.
t_min
.
x
,
f
.
t_max
.
y
-
f
.
t_min
.
y
);
break
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment