Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
glkink
/
C-programming
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
d9b76ec3
authored
Jan 23, 2022
by
glkink
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
67c088c2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
KTül2
KTül2
0 → 100644
View file @
d9b76ec3
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int loeKokku(int massiiv[], int pikkusM, int miinimum, int maksimum)
{
// Oletame, et kõik numbrid jäävad võtmeväärtusest väljapoole
int loe = maksimum - miinimum;
for (int i = 0; i < pikkusM; i++)
{
int repeat = 0; // 0 tähendab, et number ei kordu
//kontrolli korduse tingimust
for (int j = 0; j < i; j++)
if (massiiv[j] == massiiv[i]) // Kui number kordub
{
repeat = 1;
break;
}
if (repeat == 0)
loe--;
}
return loe;
}
int main()
{
srand(time(NULL));
int pikkus, min, max, valja;
printf("Massiivi pikkus: \n");
scanf("%d", &pikkus);
printf("Miinimum vaartused: \n");
scanf("%d", &min);
printf("Maksimum vaartused: \n");
scanf("%d", &max);
int massiiv[pikkus];
for (int i = 0; i < pikkus; ++i)
{
massiiv[i] = rand() % (max + min);
}
valja = loeKokku(massiiv, pikkus, min, max);
printf("%d arvu jaid vahemikust valja.\n", valja);
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