Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
mikolo
/
paaristoo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3025a434
authored
Feb 13, 2023
by
albrat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update functions.c
parent
f2fe2349
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
25 deletions
functions.c
functions.c
View file @
3025a434
...
@@ -8,14 +8,11 @@ void load_autos(Auto *autos) {
...
@@ -8,14 +8,11 @@ void load_autos(Auto *autos) {
return
;
return
;
}
}
for
(
int
i
=
0
;
i
<
MAX_AUTOS
;
i
++
)
{
for
(
int
i
=
0
;
i
<
MAX_AUTOS
;
i
++
)
{
fscanf
(
fp
,
"%s %s %s %d %s"
,
autos
[
i
].
mark
,
autos
[
i
].
model
,
autos
[
i
].
license_plate
,
&
autos
[
i
].
year
,
autos
[
i
].
engine_size
);
fscanf
(
fp
,
"%s %s %s %d %s"
,
autos
[
i
].
mark
,
autos
[
i
].
model
,
autos
[
i
].
license_plate
,
&
autos
[
i
].
year
,
autos
[
i
].
engine_size
);
}
}
fclose
(
fp
);
fclose
(
fp
);
}
}
void
load_owners
(
Owner
*
owners
)
{
void
load_owners
(
Owner
*
owners
)
{
...
@@ -25,60 +22,48 @@ void load_owners(Owner *owners) {
...
@@ -25,60 +22,48 @@ void load_owners(Owner *owners) {
return
;
return
;
}
}
for
(
int
i
=
0
;
i
<
MAX_OWNERS
;
i
++
)
{
for
(
int
i
=
0
;
i
<
MAX_OWNERS
;
i
++
)
{
fscanf
(
fp
,
"%s %s"
,
owners
[
i
].
id
,
owners
[
i
].
name
);
fscanf
(
fp
,
"%s %s"
,
owners
[
i
].
id
,
owners
[
i
].
name
);
}
}
fclose
(
fp
);
fclose
(
fp
);
}
}
void
find_most_powerful_car
(
Auto
*
autos
)
{
void
find_most_powerful_car
(
Auto
*
autos
)
{
int
max_index
=
0
;
int
max_index
=
0
;
float
max_engine_size
=
0
;
for
(
int
i
=
1
;
i
<
MAX_AUTOS
;
i
++
)
{
for
(
int
i
=
0
;
i
<
MAX_AUTOS
;
i
++
)
{
if
(
autos
[
i
].
engine_size
>
autos
[
max_index
].
engine_size
)
{
float
engine_size
;
sscanf
(
autos
[
i
].
engine_size
,
"%f"
,
&
engine_size
);
if
(
engine_size
>
max_engine_size
)
{
max_engine_size
=
engine_size
;
max_index
=
i
;
max_index
=
i
;
}
}
}
}
printf
(
"Most powerful car: %s %s
\n
"
,
autos
[
max_index
].
mark
,
autos
[
max_index
].
model
);
printf
(
"Most powerful car: %s %s
\n
"
,
autos
[
max_index
].
mark
,
autos
[
max_index
].
model
);
}
}
void
find_oldest_car
(
Auto
*
autos
)
{
void
find_oldest_car
(
Auto
*
autos
)
{
int
min_index
=
0
;
int
min_index
=
0
;
for
(
int
i
=
1
;
i
<
MAX_AUTOS
;
i
++
)
{
for
(
int
i
=
1
;
i
<
MAX_AUTOS
;
i
++
)
{
if
(
autos
[
i
].
year
<
autos
[
min_index
].
year
)
{
if
(
autos
[
i
].
year
<
autos
[
min_index
].
year
)
{
min_index
=
i
;
min_index
=
i
;
}
}
}
}
printf
(
"Oldest car: %s %s
\n
"
,
autos
[
min_index
].
mark
,
autos
[
min_index
].
model
);
printf
(
"Oldest car: %s %s
\n
"
,
autos
[
min_index
].
mark
,
autos
[
min_index
].
model
);
}
}
void
find_newest_car
(
Auto
*
autos
)
{
void
find_newest_car
(
Auto
*
autos
)
{
int
max_index
=
0
;
int
max_index
=
0
;
for
(
int
i
=
1
;
i
<
MAX_AUTOS
;
i
++
)
{
for
(
int
i
=
1
;
i
<
MAX_AUTOS
;
i
++
)
{
if
(
autos
[
i
].
year
>
autos
[
max_index
].
year
)
{
if
(
autos
[
i
].
year
>
autos
[
max_index
].
year
)
{
max_index
=
i
;
max_index
=
i
;
}
}
}
}
printf
(
"Newest car: %s %s
\n
"
,
autos
[
max_index
].
mark
,
autos
[
max_index
].
model
);
printf
(
"Newest car: %s %s
\n
"
,
autos
[
max_index
].
mark
,
autos
[
max_index
].
model
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment