-
Notifications
You must be signed in to change notification settings - Fork 0
/
Odd and Even Numbers Decomposition
52 lines (44 loc) · 1.08 KB
/
Odd and Even Numbers Decomposition
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdio.h>
int sayi;
int denemedizi[100];
int ciftdizi[100];
int tekdizi[100];
int sayaca=0;
int sayacb=0;
int main() {
printf("Kac elemanli bir dizi gireceksiniz?\n");
scanf("%d", &sayi);
for (int i = 0; i < sayi; i++) {
printf("Dizinizi giriniz:\n");
scanf("%d", &denemedizi[i]);
}
for (int i = 0; i < sayi; i++) {
if (denemedizi[i] % 2 == 0) {
ciftdizi[i] = denemedizi[i];
sayaca++;
} else if(denemedizi[i] % 2 != 0)
continue;
}
for (int i = 0; i < sayi; i++) {
if (denemedizi[i] % 2 == 1) {
tekdizi[i] = denemedizi[i];
sayacb++;
} else if(denemedizi[i] % 2 != 1)
continue;
}
printf("Cift diziniz:\n");
for (int k = 0; k < sayi; k++) {
if (ciftdizi[k]!=0)
printf("%3d", ciftdizi[k]);
else
continue;
}
printf("\nTek diziniz:\n");
for (int l = 0; l < sayi; l++) {
if (tekdizi[l]!=0)
printf("%3d", tekdizi[l]);
else
continue;
}
return 0;
}