-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathDiziEnBuyuk.cpp
45 lines (31 loc) · 896 Bytes
/
DiziEnBuyuk.cpp
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
#include<iostream>
#include<time.h>
using namespace std;
int main()
{
srand(time(0)); // random besleme fonksiyonu
int temp=NULL;
int dizi[10]; // dizi tanımlama
for(int i=0;i<10;i++) // diziye rastgele deger atama dongusu
dizi[i]=rand()%10+1; // 0-10 (dahil) arasında deger ata.
cout<<"--------Before--------"<<endl;
for(int i=0;i<10;i++) // diziyi ekrana bas.
cout<<dizi[i]<<" ";
cout<<endl<<"--------After--------"<<endl;
temp=dizi[0];
for(int i=0;i<10;i++)
{
for(int j=0;j<10;j++)
{
if(dizi[i] < dizi[j])
{
temp=dizi[j];
dizi[j]=dizi[i]; // yer degistirme islemleri yapiliyor.
dizi[i]=temp;
}
}
}
for(int i=0;i<10;i++) // diziyi ekrana bas.
cout<<dizi[i]<<" ";
return 0;
}