Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
edtell
/
Programmeerimine_II_KT1
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
c962bb26
authored
Feb 16, 2023
by
edtell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
1a35f7bc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
0 deletions
funkts.c
funkts.c
0 → 100644
View file @
c962bb26
#include "header.h"
void
input
(
FILE
*
sisse
,
Inim
*
keegi
)
// Viit muutujale keegi
{
fscanf
(
sisse
,
"%s %d %d,%d,%d,%d
\n
"
,
keegi
->
nimi
,
&
keegi
[
0
].
kood
,
&
keegi
[
0
].
hinne
[
0
],
&
keegi
[
0
].
hinne
[
1
],
&
keegi
[
0
].
hinne
[
2
],
&
keegi
[
0
].
hinne
[
3
]);
}
void
stip
(
FILE
*
valja
,
Inim
*
keegi
,
int
N
){
for
(
int
i
=
0
;
i
<
N
;
i
++
){
if
(
keegi
[
i
].
hinne
[
0
]
==
5
&&
keegi
[
i
].
hinne
[
1
]
==
5
&&
keegi
[
i
].
hinne
[
2
]
==
5
&&
keegi
[
i
].
hinne
[
3
]
==
5
){
fprintf
(
valja
,
"%s %d %d
\n
"
,
keegi
[
i
].
nimi
,
keegi
[
i
].
kood
,
100
);
}
else
if
(
keegi
[
i
].
hinne
[
0
]
>=
4
&&
keegi
[
i
].
hinne
[
1
]
>=
4
&&
keegi
[
i
].
hinne
[
2
]
>=
4
&&
keegi
[
i
].
hinne
[
3
]
>=
4
){
fprintf
(
valja
,
"%s %d %d
\n
"
,
keegi
[
i
].
nimi
,
keegi
[
i
].
kood
,
75
);
}
else
{
fprintf
(
valja
,
"%s %d %d
\n
"
,
keegi
[
i
].
nimi
,
keegi
[
i
].
kood
,
0
);
}
}
rewind
(
valja
);
Inim
buff
[
N
];
for
(
int
j
=
0
;
j
<
N
;
j
++
){
fscanf
(
valja
,
"%s %d %d"
,
buff
[
j
].
nimi
,
&
buff
[
j
].
kood
,
&
buff
[
j
].
hinne
[
0
]);
}
rewind
(
valja
);
int
m
,
d
;
Inim
vaheta
;
for
(
m
=
0
;
m
<
N
-
1
;
m
++
)
{
for
(
d
=
0
;
d
<
N
-
m
-
1
;
d
++
)
{
if
(
buff
[
d
].
hinne
[
0
]
<
buff
[
d
+
1
].
hinne
[
0
])
{
vaheta
=
buff
[
d
];
buff
[
d
]
=
buff
[
d
+
1
];
buff
[
d
+
1
]
=
vaheta
;
}
else
if
(
buff
[
d
].
hinne
[
0
]
==
buff
[
d
+
1
].
hinne
[
0
]){
if
(
buff
[
d
].
nimi
[
0
]
>=
buff
[
d
+
1
].
nimi
[
0
]){
vaheta
=
buff
[
d
];
buff
[
d
]
=
buff
[
d
+
1
];
buff
[
d
+
1
]
=
vaheta
;
}
}
}
}
rewind
(
valja
);
for
(
int
h
=
0
;
h
<
N
;
h
++
){
fprintf
(
valja
,
"%s %d %d %s
\n
"
,
buff
[
h
].
nimi
,
buff
[
h
].
kood
,
buff
[
h
].
hinne
[
0
],
"eur"
);
}
rewind
(
valja
);
if
(
!
feof
(
valja
)){
printf
(
"Tehtud!
\n
"
);
printf
(
"Kontrolllige Output faili"
);
}
}
void
fnimi
(
char
*
nimi
,
char
*
tekst
){
printf
(
"%s"
,
tekst
);
scanf
(
"%s"
,
nimi
);
}
int
loe
(
FILE
*
sisse
){
int
i
=
0
;
char
buff
[
59
];
int
buff2
,
buff3
[
4
];
while
(
fscanf
(
sisse
,
"%s %d %d,%d,%d,%d"
,
buff
,
&
buff2
,
&
buff3
[
0
],
&
buff3
[
1
],
&
buff3
[
2
],
&
buff3
[
3
])
!=
EOF
){
i
++
;
}
rewind
(
sisse
);
return
i
;
}
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