-
Notifications
You must be signed in to change notification settings - Fork 2
/
FunçãoPonteiros2.c
65 lines (53 loc) · 968 Bytes
/
FunçãoPonteiros2.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
65
#include <stdio.h>
int maior(float a, float b)
{
if(a>b)
return 1;
return 0;
}
int menor(float a, float b)
{
if(a<b)
return 1;
return 0;
}
void ordena(float *vetor, int n, int (*func)(float,float))
{
int i;
int j;
float aux;
for(i=0; i<n; i++)
{
for(j=0; j<n-1; j++)
{
if( func( vetor[j],vetor[j+1] )==0 )
{
aux = vetor[j];
vetor[j] = vetor[j+1];
vetor[j+1] = aux;
}
}
}
}
int main()
{
int i;
float a[10];
for(i = 0; i < 10; i++)
{
scanf("%f",&a[i]);
}
ordena(a,10,menor);
for(i = 0; i < 10; i++)
{
printf("%.1f ",a[i]);
}
printf("\n\n");
ordena(a,10,maior);
for(i = 0; i < 10; i++)
{
printf("%.1f ",a[i]);
}
system ("pause");
return 0;
}