Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Jürgen Hein
/
iax0583
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
a7fe571f
authored
Oct 10, 2024
by
Jürgen Hein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
a7faa468
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
Tunnitöö 10.10.24/MassiivFunktsioonid.c
Tunnitöö 10.10.24/MassiivFunktsioonid.c
0 → 100644
View file @
a7fe571f
//Kasutaja sisestab nxn massiivi (2d maatriks) klaviatuurilt,
//Kasutaja sisestab nxn massiivi (2d maatriks) klaviatuurilt,
//iga tulba minimaalsed elemendid
//salvestatakse uuele 1d massiivile.
//Väljastatakse minimaalsete elementide massiiv.
//Minimaalselt 3 alamprogrammi.
#include <stdio.h>
int
sisestus
(
char
[]);
void
maatriksSisse
(
int
o
,
int
[
o
][
o
]);
//2d massiividele vajalik teine mõõde
void
v
ä
ljastusMM
(
int
o
,
int
[
o
][
o
]);
void
tulpMin
(
int
o
,
int
[
o
][
o
],
int
[]);
void
v
ä
ljastusM
(
char
[],
int
,
int
[]);
int
main
(
void
){
int
n
;
n
=
sisestus
(
"Sisesta ruutmaatriksi mõõde:"
);
int
maatriks
[
n
][
n
];
int
tulpadeMiinimumid
[
n
];
maatriksSisse
(
n
,
maatriks
);
v
ä
ljastusMM
(
n
,
maatriks
);
tulpMin
(
n
,
maatriks
,
tulpadeMiinimumid
);
v
ä
ljastusM
(
"Tulpade minimaalsed elemendid:
\n
"
,
n
,
tulpadeMiinimumid
);
return
0
;
}
int
sisestus
(
char
teade
[]){
int
c
;
printf
(
"%s"
,
teade
);
scanf
(
"%d"
,
&
c
);
return
c
;
}
void
maatriksSisse
(
int
K
,
int
m
[
K
][
K
]){
int
i
,
j
;
for
(
i
=
0
;
i
<
K
;
i
++
){
for
(
j
=
0
;
j
<
K
;
j
++
){
printf
(
"Sisesta element rida %d, tulp %d:"
,
i
,
j
);
scanf
(
"%d
\n
"
,
&
m
[
i
][
j
]);
}
}
}
void
v
ä
ljastusMM
(
int
K
,
int
m
[
K
][
K
]){
int
i
,
j
;
printf
(
"Sisestatud maatriks:
\n
"
);
for
(
i
=
0
;
i
<
K
;
i
++
){
printf
(
"
\n
"
);
for
(
j
=
0
;
j
<
K
;
j
++
){
printf
(
"%d "
,
m
[
i
][
j
]);
}
}
}
void
tulpMin
(
int
K
,
int
m
[
K
][
K
],
int
colMinima
[]){
int
i
,
j
,
min
;
for
(
j
=
0
;
j
<
K
;
j
++
)
{
min
=
m
[
0
][
j
];
// Võtame tulba esimese elemendi algväärtuseks
for
(
i
=
1
;
i
<
K
;
i
++
)
{
if
(
m
[
i
][
j
]
<
min
)
{
min
=
m
[
i
][
j
];
}
}
colMinima
[
j
]
=
min
;
}
printf
(
"
\n
"
);
}
void
v
ä
ljastusM
(
char
teade
[],
int
K
,
int
m
[]){
printf
(
"%s"
,
teade
);
int
i
;
for
(
i
=
0
;
i
<
K
;
i
++
)
{
printf
(
"%d "
,
m
[
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