Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
raliis
/
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
ac47012f
authored
Oct 30, 2017
by
raliis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
32462ccf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
0 deletions
suusahype.c
suusahype.c
0 → 100644
View file @
ac47012f
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int
main
()
{
srand
(
time
(
NULL
));
// genereerib suvalise arvu seemne aja järgi
int
N
;
// massiivi tulpade arv
int
i
,
j
,
k
;
// loendurid
int
l
=
3
;
// lisaloendur laius
int
temp
;
// ajutine muutuja
int
randSize
=
5
;
float
keskmine
;
//N sisestamine
printf
(
"Sisesta tabeli tulpade arv N:
\n
"
);
scanf
(
"%d"
,
&
N
);
// N kontroll
while
(
N
<=
0
||
N
>
15
)
{
printf
(
"N peab olema vähemalt 1 ja väiksem kui 15, "
"sisesta uus N:
\n
"
);
scanf
(
"%d"
,
&
N
);
printf
(
"
\n
"
);
}
int
H
[
N
][
5
];
// hinnete massiivi deklareerimine
//suvaliste arvude genereerimine
for
(
i
=
0
;
i
<
N
;
i
++
)
{
for
(
j
=
0
;
j
<
5
;
j
++
)
{
H
[
i
][
j
]
=
rand
()
%
randSize
;
printf
(
"%d"
,
H
[
i
][
j
]);
}
printf
(
"
\n
"
);
}
printf
(
"
\n
"
);
//sortimine
for
(
k
=
0
;
k
<
N
;
k
++
)
{
for
(
i
=
0
;
i
<
N
;
i
++
)
{
for
(
j
=
0
;
j
<
4
;
j
++
)
{
if
(
H
[
i
][
j
]
>
H
[
i
][
j
+
1
])
{
temp
=
H
[
i
][
j
];
H
[
i
][
j
]
=
H
[
i
][
j
+
1
];
H
[
i
][
j
+
1
]
=
temp
;
}
}
}
}
//sorditud arvude printimine
for
(
i
=
0
;
i
<
N
;
i
++
)
{
for
(
j
=
0
;
j
<
5
;
j
++
)
{
printf
(
"%d"
,
H
[
i
][
j
]);
}
printf
(
"
\n
"
);
}
printf
(
"
\n
"
);
//keskmiste väärtuste arvutamine
for
(
i
=
0
;
i
<
N
;
i
++
)
{
keskmine
=
H
[
i
][
1
]
+
H
[
i
][
2
]
+
H
[
i
][
3
];
keskmine
=
keskmine
/
3
;
printf
(
"%d rea keskmine on: %.3f
\n
"
,
i
,
keskmine
);
}
return
0
;
}
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