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
d5ac33df
authored
Sep 21, 2024
by
Jürgen Hein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
53046174
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
0 deletions
Tunnitöö 19.09.24/MassiivMaxMin.c
Tunnitöö 19.09.24/MassiivMaxMin.c
0 → 100644
View file @
d5ac33df
/*Programm, mis loob massiivi S[k][k](võib olla ka suvalise suurusega)
/*Programm, mis loob massiivi S[k][k](võib olla ka suvalise suurusega)
* ning trükib ekraanile, leiab massiivis minimaalse väärtuse ja
* maksimaalse väärtuse. Leiab kaks massiivi: massiivi elemente jagades
* minimaalse ning teine jagades maksimaalse väärtusega.
* Teosta 3 massiivi (algne, jagatis min, jagatis max) väljatrükk.
*
* Esitatud on Blackbox AI lahendus minu kirjutatud algoritmile.
* AI tegi tehte SMax / S[i][j]. Õige oleks S[i][j]/SMax.
* Samuti võiks algoritmis pikalt kirjutatud mõned while laused võtta kokku
* for lausetega nt for(i=0;i<n;i++){}.
*/
#include <stdio.h>
int
main
()
{
int
n
,
i
,
j
,
SMax
,
SMin
;
// Algväärtustamine
do
{
printf
(
"Sisestada number n (2-10): "
);
scanf
(
"%d"
,
&
n
);
}
while
(
n
<
2
||
n
>
10
);
int
S
[
n
][
n
],
MaxJagatis
[
n
][
n
],
MinJagatis
[
n
][
n
];
// Sisestamine
i
=
0
;
while
(
i
<
n
)
{
j
=
0
;
while
(
j
<
n
)
{
printf
(
"Sisestada arv kohal S[%d][%d]: "
,
i
,
j
);
scanf
(
"%d"
,
&
S
[
i
][
j
]);
j
++
;
}
i
++
;
}
// Arvutused
SMax
=
S
[
0
][
0
];
SMin
=
S
[
0
][
0
];
i
=
0
;
while
(
i
<
n
)
{
j
=
0
;
while
(
j
<
n
)
{
if
(
S
[
i
][
j
]
>
SMax
)
{
SMax
=
S
[
i
][
j
];
}
if
(
S
[
i
][
j
]
<
SMin
)
{
SMin
=
S
[
i
][
j
];
}
j
++
;
}
i
++
;
}
// Jagajate leidmine
i
=
0
;
while
(
i
<
n
)
{
j
=
0
;
while
(
j
<
n
)
{
MaxJagatis
[
i
][
j
]
=
SMax
/
S
[
i
][
j
];
MinJagatis
[
i
][
j
]
=
SMin
/
S
[
i
][
j
];
j
++
;
}
i
++
;
}
// Tulemuste kuvamine
printf
(
"
\n
Sisestatud maatriks:
\n
"
);
i
=
0
;
while
(
i
<
n
)
{
j
=
0
;
while
(
j
<
n
)
{
printf
(
"%d "
,
S
[
i
][
j
]);
j
++
;
}
printf
(
"
\n
"
);
i
++
;
}
printf
(
"
\n
Suurima elemendi jagajad:
\n
"
);
i
=
0
;
while
(
i
<
n
)
{
j
=
0
;
while
(
j
<
n
)
{
printf
(
"%d "
,
MaxJagatis
[
i
][
j
]);
j
++
;
}
printf
(
"
\n
"
);
i
++
;
}
printf
(
"
\n
Väikseima elemendi jagajad:
\n
"
);
i
=
0
;
while
(
i
<
n
)
{
j
=
0
;
while
(
j
<
n
)
{
printf
(
"%d "
,
MinJagatis
[
i
][
j
]);
j
++
;
}
printf
(
"
\n
"
);
i
++
;
}
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