-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpecial Patterns
148 lines (124 loc) · 3.87 KB
/
Special Patterns
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include <stdio.h>
int secim;
float k;
float tekdizi[9000];
float m;
float ciftdizi[9000];
float x;
int sayac=1;
float fibo[9000];
float y;
float ucgendizi[9000];
float z;
float karedizi[9000];
float a, b, c;
float ardisikdizi[9000];
int main() {
printf("Sayi Dizileri Yazdirma Programina Hosgeldiniz!\n");
printf("Tek Sayi Dizisi Icin 1:\n");
printf("Cift Sayi Dizisi Icin 2:\n");
printf("Fibonacci Dizisi Icin 3:\n");
printf("Ucgensel Dizi Icin 4:\n");
printf("Karesel Dizi Icin 5:\n");
printf("Aritmetik Dizi Icin 6:\n");
printf("tuslayiniz...\n");
scanf("\n%d", &secim);
switch (secim) {
case 1:
printf("Tek Sayi Dizisinin Kac Eleman Devam Edecegini Belirleyiniz:\n");
scanf("%f", &k);
for (int i=2; i<=k; i++) {
tekdizi[0]=1;
tekdizi[1]=3;
tekdizi[i]=i+i+1;
}
printf("Diziniz:\n");
for (int i=0; i<=k-1; i++) {
printf("%5.0f", tekdizi[i]);
}
break;
case 2:
printf("Cift Sayi Dizisinin Kac Eleman Devam Edecegini Belirleyiniz:\n");
scanf("%f", &m);
for (int i=0; i<=m; i++) {
ciftdizi[i]=i*2;
}
printf("Diziniz:\n");
for (int i=0; i<=m-1; i++) {
printf("%5.0f", ciftdizi[i]);
}
break;
case 3:
printf("Fibonacci Sayi Dizisinin Kac Eleman Devam Edecegini Belirleyiniz:\n");
scanf("%f", &x);
fibo[0]=1;
fibo[1]=1;
for (int i=2; i<=x; i++) {
fibo[i]=fibo[i-1]+fibo[i-2];
sayac++;
}
printf("Diziniz:\n");
for (int i=0; i<=sayac-1; i++) {
printf("%8.0f", fibo[i]);
}
break;
case 4:
printf("Ucgensel Sayi Dizisinin Kac Eleman Devam Edecegini Belirleyiniz:\n");
scanf("%f", &y);
for (int i=1; i<=y; i++) {
ucgendizi[0]=1;
ucgendizi[i]=(i+1)*(i+2)/2;
}
printf("Diziniz:\n");
for (int i=0; i<=y; i++) {
printf("%5.0f", ucgendizi[i]);
}
break;
case 5:
printf("Karesel Sayi Dizisinin Kac Eleman Devam Edecegini Belirleyiniz:\n");
scanf("%f", &z);
for (int i=1; i<=z; i++) {
karedizi[0]=1;
karedizi[i]=(i+1)*(i+1);
}
printf("Diziniz:\n");
for (int i=0; i<=z-1; i++) {
printf("%5.0f", karedizi[i]);
}
break;
case 6:
printf("Lutfen dizinin baslangic degerini giriniz:\n");
scanf("%f", &a);
printf("Lutfen dizinin bitis degerini giriniz:\n");
scanf("%f", &b);
printf("Dizinin ardisik azalma ya da artma miktarini giriniz:\n");
scanf("%f", &c);
if (a<b) {
for (int i=0; i<=b; i++) {
ardisikdizi[0]=a;
ardisikdizi[i]=a+c*(i);
}
float tsayi=(b-a)/c+1;
printf("Diziniz:\n");
for (int i=0; i<=tsayi-1; i++) {
printf("%5.0f", ardisikdizi[i]);
}
}
else if (a>b) {
for (int i=0; i<=b; i++) {
ardisikdizi[0]=a;
ardisikdizi[i]=a-c*(i);
}
float tsayi=(a-b)/c+1;
printf("Diziniz:\n");
for (int i=0; i<=tsayi-1; i++) {
printf("%5.0f", ardisikdizi[i]);
}
}
else {
printf("İki sayiyi esit girdiniz, cevap sadece: %f", a);
}
break;
}
return 0;
}