-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
182 lines (134 loc) · 3.91 KB
/
Program.cs
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _06_Arrays
{
internal class Program
{
static void Main(string[] args)
{
#region Temel Dizi Örnekleri
//Diziler aynı veri tipindeki çok sayıdaki verileri bir arada tutmak için kullanılabilir.
//Değişken türü[] dizi=new DeğişkenTürü[ElemanSayısı]
//string[] colors =new string[4];
//colors[0] = "Kırmızı";
//colors[1] = "Sarı";
//colors[2] = "Beyaz";
//colors[3] = "Mavi";
//Console.WriteLine(colors[2]);
//string[] cities = new string[5];
//cities[0] = "Milano";
//cities[1] = "Budapeşte";
//cities[2] = "Lyon";
//cities[3] = "Kahire";
//cities[4] = "Üsküp";
//Console.WriteLine(cities[4]);
//int[]numbers=new int[10];
//numbers[0] = 50;
//numbers[1] = 48;
//numbers[2] = 698;
//numbers[3] = 24;
//numbers[7] = 748;
//Console.WriteLine(numbers[7]);
//string[] cities = { "Prag", "Roma", "Atina", "Ankara", "Bursa" };
//Console.WriteLine(cities[2]);
#endregion
#region Dizideki Tüm Elemanları Listeleme
//string[] colors = { "Sarı", "Kırmızı", "Beyaz", "Mavi", "Yeşil", "Turuncu", "Pembe" };
//for(int i=0;i<colors.Length; i++)
//{
// Console.WriteLine(colors[i]);
//}
//int[] numbers = { 4, 85, 96, 75, 125, 635, 488, 522, 7456, 2365, 1120 };
//for(int i=0; i<numbers.Length; i++)
//{
// if (numbers[i] % 3 == 0)
// {
// Console.WriteLine(numbers[i]);
// }
//}
//char[] symbols = { 'a', 'b', 'c', '*', '/', '-' };
//for(int i=0;i<symbols.Length; i++)
//{
// Console.WriteLine(symbols[i]);
//}
//int[] myArray = { 47, 85, 95, 41, 25, 635, 789, 86, 100 };
//int maxNumber = myArray[0];
//for(int i=0;i<myArray.Length;i++)
//{
// if (myArray[i] > maxNumber)
// {
// maxNumber = myArray[i];
// }
//}
//Console.WriteLine(maxNumber);
//string[] persons = { "ali", "ahmet", "ayşe", "buse", "cem", "deniz" };
//Console.WriteLine(persons.Length);
//int[] numbers = { 45, 85, 52, 41, 86, 10, 22, 35 };
//Array.Sort(numbers);
//for(int i=0; i < numbers.Length; i++)
//{
// Console.WriteLine(numbers[i]);
//}
//int[] numbers = { 45, 85, 52, 41, 86, 10, 22, 35 };
//Array.Reverse(numbers);
//for (int i = 0; i < numbers.Length; i++)
//{
// Console.WriteLine(numbers[i]);
//}
#endregion
#region Dizi Merorları
//string[] customers = { "ali", "buse", "atşegül", "merve", "çınar", "kaya" };
//int index = Array.IndexOf(customers, "merve");
//Console.WriteLine(index);
//int[] numbers = { 45, 85, 96, 63, 74, 10, 25, 22, 36 };
//Console.WriteLine("Dizinin en büyük elemanı: " + numbers.Max() + " Dizinin en küçük elemanı: " + numbers.Min());
#endregion
#region Kullanıcıdan Değer Alma
//string[] cites = new string[5];
//for(int i = 0; i < cites.Length; i++)
//{
// Console.Write($"Lütfen {i + 1}. Şehri Giriniz: ");
// cites[i] = Console.ReadLine();
//}
//Console.WriteLine();
//Console.WriteLine("--------------");
//for(int i=0;i<cites.Length;i++)
//{
// Console.WriteLine(cites[i]);
//}
//int[] numbers = { 10, 20, 30, 40, 50 };
//int sum = 0;
//for(int i = 0; i < numbers.Length; i++)
//{
// sum+= numbers[i];
//}
//Console.WriteLine(sum);
int[] numbers = { 21, 42, 33, 54, 55, 66, 897, 748, 39, 220 };
Console.WriteLine("Çift Sayılar");
Console.WriteLine();
for (int i=0; i < numbers.Length; i++)
{
if (numbers[i]%2== 0)
{
Console.WriteLine(numbers[i]);
}
}
Console.WriteLine();
Console.WriteLine("----------------");
Console.WriteLine("Tek Sayılar");
Console.WriteLine();
for (int i=0;i<numbers.Length; i++)
{
if (numbers[i]%2== 1)
{
Console.WriteLine(numbers[i]);
}
}
#endregion
Console.Read();
}
}
}