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
68e86182
authored
Sep 22, 2024
by
Jürgen Hein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
8e0f312f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
Kuu ülesanded 1/Ülesanne 1 (Paaris ja paaritud arvud)/PaarisPaaritu.c
Kuu ülesanded 1/Ülesanne 1 (Paaris ja paaritud arvud)/PaarisPaaritu.c
0 → 100644
View file @
68e86182
/*Kirjutage programm, mis sisestab N(N<15,N>3) täisarvu ja
/*Kirjutage programm, mis sisestab N(N<15,N>3) täisarvu ja
väljastab, kui palju oli paaris ja mitu paaritut. */
#include <stdio.h>
int
main
(
void
)
{
int
N
;
//Massiivi suurus
int
i
;
//arvu järjenumber
int
k
=
0
;
//paarisarvude järjenumber
int
l
=
0
;
//paaritute arvude järjenumber
//sisestus
do
{
printf
(
"Palun sisestage, mitu täisarvu soovite sisestada (3...15)"
);
scanf
(
"%d"
,
&
N
);
}
while
(
3
>
N
||
N
>
15
);
int
T
[
N
];
//Kõik täisarvud
for
(
i
=
0
;
i
<
N
;
i
++
)
{
printf
(
"Sisestada arv kohal T[%d]: "
,
i
);
scanf
(
" %d"
,
&
T
[
i
]);
}
int
Paaris
[
N
];
int
Paaritu
[
N
];
//töötlus
for
(
i
=
0
;
i
<
N
;
i
++
)
{
if
(
T
[
i
]
%
2
==
0
)
//kontroll, kas arv on paarisarv
{
Paaris
[
k
]
=
T
[
i
];
k
++
;
}
else
{
Paaritu
[
l
]
=
T
[
i
];
//Arv on paaritu
l
++
;
}
}
//väljastus
printf
(
"Paarisarve on %d
\n
"
,
k
);
printf
(
"Paarituid arve on %d"
,
l
);
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