-
Notifications
You must be signed in to change notification settings - Fork 0
/
ordenacaoC.c
60 lines (54 loc) · 1.15 KB
/
ordenacaoC.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
#include <stdio.h>
void ordenacaoC(int *v, int n){
int elem, i, j;
for(i=0; i<n; i++){
elem = v[i];
for(j = i-1 ; j >= 0 && v[j]>elem; j--){
v[j+1] = v[j];
}
v[j+1] = elem;
}
}
/*void ordenacaoC(int *v, int size) {
int pivot, j, i = 1;
while (i <= size){
//printf("oi");
pivot = v[i];
j = i-1;
while (v[j] > pivot && v[j] >= 0){
//printf("oi");
v[j+1] = v[j];
j--;
}
v[j+1] = pivot;
i++;
}
}*/
int main (){
/*int h;
int v[8] = {100, 25, 5, 3, 2, 4, 1, 41};
ordenacaoC(v, 8);
for(h = 0; h < 8; h++){
printf("%d ", v[h]);
}*/
/*int x, ret;
int i = 0;
int v[];
ret = scanf("%d", &x);
while (ret != EOF){
printf("Valor lido: %d\n", x);
ret = scanf("%d", &x);
}*/
int v[1000];
int h = 0;
int i, x;
while (scanf("%d", &x) != EOF){
v[h] = x;
h++;
}
ordenacaoC(v, h);
for(i = 0; i < h; i++){
printf("%d ", v[i]);
}
return 0;
}