-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpointerCalismaCDizi.cpp
More file actions
53 lines (49 loc) · 906 Bytes
/
Copy pathpointerCalismaCDizi.cpp
File metadata and controls
53 lines (49 loc) · 906 Bytes
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
53
#include<stdio.h>
#include<stdlib.h>
#define SIZE 100
#include<string.h>
#include<time.h>
//pointer kullanarak dizinin tek elemanlarýný tek diziye çift olanlarý çift diziye ekleyelim
int main()
{
int dizi[20];
int cDizi[10],tDizi[10];
int *cSayac,*tSayac;
tSayac=tDizi;
cSayac=cDizi;
int *ptr;
ptr=dizi;
srand(time(0));
for(int i=0;i<20;i++)
{
*(ptr+i)=rand()%10;
}
printf("Orijinal dizi:\n");
for(int i=0;i<20;i++)
{
printf("%d\n",*(ptr+i));
}
for(int i=0;i<20;i++)
{
if(*(ptr+i)%2==0)
{
*cSayac=*(ptr+i);
cSayac++;
}
else{
*tSayac=*(ptr+i);
tSayac++;
}
}
printf("Cift sayilar:\n");
for(int *ptr=cDizi;ptr<cSayac;ptr++)
{
printf("%d\n",*ptr);
}
printf("\n");
printf("Tek sayilar:\n");
for (int *ptr = tDizi; ptr < tSayac; ptr++) {
printf("%d ", *ptr);
}
printf("\n");
}