-
Notifications
You must be signed in to change notification settings - Fork 0
/
Diziler-4.c
64 lines (62 loc) · 1.24 KB
/
Diziler-4.c
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
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// Sıralamalar
void sortIt();
void writeTheArray();
int numbers[7], i;
int main()
{
// int numbers[7], i;
// printf("Enter array numbers: ");
// for (i = 0; i < 7; i++)
// {
// scanf("%d", &numbers[i]);
// }
// printf("Original order:");
// for (i = 0; i < 7; i++)
// {
// printf("%d ", numbers[i]);
// }
// printf("\nReverse order:");
// for (i = 0; i < 7; i++)
// {
// printf("%d ", numbers[6 - i]);
// }
printf("Enter array numbers:");
for (i = 0; i < 7; i++)
{
scanf("%d", &numbers[i]);
}
printf("\n Before sorting\n");
writeTheArray();
printf("\nThe array is sorting...\n");
sortIt();
printf("\nAfter sorting\n");
writeTheArray();
return 0;
}
void sortIt()
{
int j, reserve;
for (i = 0; i < 7; i++)
{
for (j = i + 1; j < 7; j++)
{
if (numbers[j] < numbers[i])
{
reserve = numbers[i];
numbers[i] = numbers[j];
numbers[j] = reserve;
}
}
}
}
void writeTheArray()
{
for ( i = 0; i < 7; i++)
{
printf("%d ",numbers[i]);
}
printf("\n");
}