-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfamily_pic_v2.c
61 lines (53 loc) · 1.08 KB
/
family_pic_v2.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
//https://thehuxley.com/problem/50
#include <stdio.h>
#include <string.h>
#define MAXN 100001
double array[MAXN];
void bubble(double a[],int tamanho, int zero, int i, int contagem)
{
int tamanho2 = (tamanho-1)*(tamanho-1);
if (contagem == tamanho2)
{
return;
}
if (i == tamanho-1)
{
return bubble(a,tamanho,zero, 0, contagem+1);
}
else
{
if (a[i]>a[i+1])
{
double aux;
aux = a[i+1];
a[i+1] = a[i];
a[i] = aux;
return bubble(a,tamanho,zero,i+1,contagem);
}
else
{
return bubble(a,tamanho,zero,i+1,contagem);
}
}
}
int main ()
{
double n1;
double n2;
double n4;
double n3;
scanf("%lf",&n1);
scanf("%lf",&n2);
scanf("%lf",&n3);
scanf("%lf",&n4);
array[0]=n1;
array[1]=n2;
array[2]=n3;
array[3]=n4;
bubble(array,4,0,0,0);
printf("%.2lf\n",array[0]);
printf("%.2lf\n",array[2]);
printf("%.2lf\n",array[3]);
printf("%.2lf\n",array[1]);
return 0;
}