Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
kmicha
/
Proge_2_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
5b7842d1
authored
Feb 27, 2024
by
kmicha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
41a539e3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
124 additions
and
0 deletions
Mitme faili versioon/funk.c
Mitme faili versioon/funk.c
0 → 100644
View file @
5b7842d1
typedef
struct
{
int
X
;
int
Y
;
}
koordinaadid
;
typedef
struct
{
koordinaadid
punkt
;
double
kaugus
;
// kaugus sisestatud punkti ja koordinaat punktide vahel
}
ring
;
void
failiNimi
(
char
failiNimetus
[
20
],
char
*
tekst
){
printf
(
"%s"
,
tekst
);
scanf
(
"%s"
,
failiNimetus
);
}
int
kontroll
(
FILE
*
input
){
if
(
input
==
NULL
){
return
1
;
}
return
0
;
}
int
failiPikkus
(
FILE
*
input
){
int
x
=
0
;
while
(
fscanf
(
input
,
"%*d %*d"
)
!=
EOF
){
x
++
;
}
rewind
(
input
);
return
x
;
}
void
taitmine
(
FILE
*
input
,
int
N
,
koordinaadid
punktd
[
N
]){
int
i
=
0
;
while
(
fscanf
(
input
,
"%d %d"
,
&
punktd
[
i
].
X
,
&
punktd
[
i
].
Y
)
!=
EOF
){
i
++
;
}
}
void
sisestus
(
int
*
raadius
,
int
*
xkoord
,
int
*
ykoord
,
char
*
radTekst
,
char
*
xTekst
,
char
*
yTekst
){
printf
(
"%s"
,
radTekst
);
scanf
(
"%d"
,
raadius
);
printf
(
"%s"
,
xTekst
);
scanf
(
"%d"
,
xkoord
);
printf
(
"%s"
,
yTekst
);
scanf
(
"%d"
,
ykoord
);
}
void
arvutus
(
int
R
,
int
Xo
,
int
Yo
,
int
N
,
koordinaadid
pnktd
[
N
],
ring
raadius
[
N
]){
int
i
,
x
,
y
,
counter
=
0
;
double
vahemaa
;
for
(
i
=
0
;
i
<
N
;
i
++
){
x
=
pnktd
[
i
].
X
;
y
=
pnktd
[
i
].
Y
;
vahemaa
=
sqrt
(
pow
((
x
-
Xo
),
2
)
+
pow
((
y
-
Yo
),
2
));
raadius
[
i
].
kaugus
=
-
1
;
// kontroll tühjaks reaks hiljem
if
(
vahemaa
<=
R
){
raadius
[
counter
].
punkt
.
X
=
pnktd
[
i
].
X
;
raadius
[
counter
].
punkt
.
Y
=
pnktd
[
i
].
Y
;
raadius
[
counter
].
kaugus
=
vahemaa
;
counter
++
;
}
}
}
void
valjastus
(
FILE
*
output
,
int
N
,
ring
sisePunktid
[
N
]){
int
i
;
printf
(
"Nr
\t
X koord
\t
Y koord
\t
Kaugus
\n
"
);
for
(
i
=
0
;
i
<
N
;
i
++
){
if
(
sisePunktid
[
i
].
kaugus
==
-
1
){
// et ei väljastaks tühja rida
continue
;
}
// Väljastus konsooli
printf
(
"%d %d
\t
%d
\t
%.2lf
\t\n
"
,
i
+
1
,
sisePunktid
[
i
].
punkt
.
X
,
sisePunktid
[
i
].
punkt
.
Y
,
sisePunktid
[
i
].
kaugus
);
// väljastus faili;
fprintf
(
output
,
"%d %d %.2lf
\n
"
,
sisePunktid
[
i
].
punkt
.
X
,
sisePunktid
[
i
].
punkt
.
Y
,
sisePunktid
[
i
].
kaugus
);
}
}
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